In the next dialog window, choose a 'Blank Activity'. Activities are Android components that hold widgets such as labels, text boxes, buttons and so on. Then hit the 'Next' button.
There are eleven initial activities to choose from. But for now, let's stick to the simplest one, the 'Blank Activity'.
TO KNOW MORE
There are mainly four components in an Android app:
Activities are application components that provide a screen. (Users can interact with it in order to do something).
Services (an application component that can perform long-running operations in the background and does not provide a user interface). As the service has no user interface, it is not bound to the lifecycle of an activity, although they run in the same process as the main thread or UI thread. Playing music or video are both examples of services.
Content Providers (an application component that manages access to a structured set of data). The Contacts application itself provides a content provider for other applications to access our contact’s data.
BroadcastReceivers (an application component that monitors device state changes). For example, you can register a receiver to have your application notified if an incoming call or battery low event arises, to take some actions.
So, select the ‘Blank activity’ and click the Next button. Eventually, the following dialog window will pop up.
Accept the default values for 'Activity Name', 'Layout Name', 'Title' and 'Menu Resource Name'. Notice that only the ‘Title’ text box can contain spaces.
Finally hit the 'Finish' button to end the whole process.
After a few seconds, a ready-to-run app made up of one Activity with its corresponding layout xml file is presented. Initially, the xml file will be displayed in the Design view but you can click the 'Text' tab to see the XML code.
As you can see the so called 'BlankActivity' is not actually blank, it has an 'onCreate' method that loads the 'activity_main.xml' file, which in turn has a label or 'TextView' that displays a “Hello World” message. Besides, a basic menu is also provided with a single item.
Now press the play button (a green triangle icon, the 15th from the left) and choose the already defined AVD to upload and display your app.
Notice that the first time you run your application, the AVD will take quite a long time to load into memory. However, successive executions won't take that much.
For this reason, you should take the time to install the Intel Hardware Accelerator mentioned in a previous unit.
But if you really want to speed up the whole process, a real device will dramatically plunge the upload time and execution, hence decreasing the overall development time. Furthermore, be aware that some crucial features just won't work in a virtual device, such as Bluetooth, NFC or GPS.
And this is how it looks like in my Samsung Galaxy S 5.
The possibilities with a real smartphone are endless ranging from GPS tracking to Bluetooth data transmission.
Just remember to choose the minimum Android version accordingly to your model. As for the Samsung Galaxy S 5, any version up to Android 5 Lollipop would work.
Optionally, you can check how your brand new app looks like in different screen sizes.
Now that you have completed your first app, it is time to digitally sign it in order to upload it to Google Play.
First, you need to create your own digital certificate with a key and certification management tool like 'keytool' which comes with the JDK.
You do not need Android Studio to sign your app.
You can sign your app from the command line using standard tools from the Android SDK and the JDK.
To sign an app in release mode from the command line:
Generate a private key using keytool. For example:
keytool -genkey -v -keystore demo.keystore -alias pep -keyalg RSA -keysize 2048 -validity 10000 This example prompts you for passwords for the keystore and for the key, and also asks to provide the Distinguished Name fields for your key. It then generates the keystore as a file called my-release-key.keystore. The keystore contains a single key, valid for 10000 days. The alias is a name that you will use later when signing your app.
Compile your app in release mode (access to Project Structure, app node, Build Types tab then choose release mode) to obtain an unsigned APK.
Sign your app with your private key using jarsigner (also provided by JDK):
zipalign -v 4 your_project_name-unaligned.apk your_project_name.apk zipalign ensures that all uncompressed data starts with a particular byte alignment relative to the start of the file, which reduces the amount of RAM consumed by an app.
As you can see there are quite a few steps. However, Android Studio, provides an easy way to do it with just one click.
In any case, you will first need the private key store you created before.
Now open up the 'Project Structure' dialog window and type the following information. Obviously, you will have to provide your own values for each text box.
CHECK IT OUT
The keytool command line tool has lots of commands and options
-printcertreq Prints the content of a certificate request
-printcrl Prints the content of a CRL file
-storepasswd Changes the store password of a keystore
Follow this link to review the whole process from a similar point of view.
Signing an Android application
And download the keytool guide.
4.3. Uploading your application to Google Play
Uploading an application to Google Play is very easy. Just create a Google account if you do not have one and then create a Google console account at:
Then sign in and click the ‘Add new application’ blue button. Notice that I have already published a couple of apps back in 2013.
As you can see, every row represents a published Android application ready to download. Each one consisting of an icon, name and version number, price, current and total installs, average rating (being 5 stars the top rating) and total rates, crashes and ANR’s (Application Not Responding) error messages, last update and status.
After hitting the ‘Add new application’ blue button, the ‘ADD NEW APPLICATION’ dialog window appears. Just write a title for your application and click the ‘Upload APK’ button then choose your APK file under the build directory in your application project’s folder.
APK stands for Android Application Package and is the package file format used to distribute and install application software and middleware onto Google’s Android operating system among others operating systems.
You must also provide a short description, full description and two icons prior to publishing your application, as well as screen captures and optionally a promotional video.
Although there are many app markets for distribution Google play is arguably the largest and most visited store in the world for Android apps.
Applications not only need to be signed with a cryptographic key that expires after October 22, 2033, the maximum size for an APK published on Google Play is 50 MB.
TO KNOW MORE
Check this link to learn more about how to publish an Android APK.