Index

Android apps - Other useful stuff

Toast - displays a pop-up message on the screen
Launch icon
Orientation of screen
App version number
Remove titles, etc. - to give you more room on the screen

Toast

This gives you a pop-up message on the screen - useful for debugging, perhaps!

Toast.makeText(getApplicationContext(), "Hello", Toast.LENGTH_SHORT).show();

There is another way to do it, but it only works in app/java/com.(the project name)/MainActivity:

Toast.makeText(MainActivity.this, "Hello", Toast.LENGTH_SHORT).show();

Neither of these will work in the GridView java - use 'mContext' rather than 'MainActivity.this'.


Launch icon

A launch icon is used to launch the app. When you look on your Kindle, you will see a charming little green robot (an android, I presume) as the icon for your app. You can have your own launch icon, and if you want to put the app on the Amazon app store, then I suggest you should.

There is not one of these launch icons but five, because they are supposed to all be at different resolutions. Still, to get this to work, I suggest making one icon and copying it to all five.

Design your icon and save it as "ic-launcher.png". It MUST have that name. Go into AndroisdStudio, and click on app/res/mipmap. This shows the five files called "ic-launcher.png". Click on each in turn, and copy your file to it. It will not only ask you if you mean it, but also point out that you're overwriting an existing file.


Orientation of screen

The screen will get re-orientated automatically. But you may prefer to force a particular orientation.

In app/manifests/AndroidManifest.xml, replace the "activity" line with the following line:
<activity android:name=".MainActivity" android:screenOrientation="portrait">

Or, of course, "landscape".


App version number

You will need to update the version number if you upload a new version of your app to Amazon app store.

Go to gradle scripts/build.gradle, and change "versionCode" and "versionName". It will say (top of screen) that it needs to sync it - click on "Sync now" (far right).


Remove titles, etc.

This gives you more room on the screen.

In app/java/com.(the project name)/MainActivity (in Java), add a statement to the "onCreate" method as follows:
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.activity_main); }

© Jo Edkins 2016 - Index to Android app index