Introduction
The GCM which was configured in the previous article, now in this article we set up in the android studio and configure the setting of our
Android application. Here are the first two part of the series,
Add GCM Activity & GCM Receiver Class
Now I add two java classes and this whole class is empty. In Image, I show you how I add one class by single-clicking on old java class and renaming it than saving it. follows the same rule for the second one class.
Add Permission
Now move to the AndroidManifest.xml file and add two permissions which are mandatory for GCM because by doing so we receive the message in our mobile.
Add GCM Activity Layout
Now simply add a blank layout in which you add one webview and give the id and set height and width property to match parent.
GCM Activity Class
Now move to GCM class and the first step is to extend with activity class then declare some class instance on class level making sure that for GoogleCloudMessaging class you want to import the GCM library which I showed you in the previous step. Now in the Oncreate method, we call the webview which is created in the previous step.
Register GCM && WEB
The first function onClick_register_gcm is basically to register the GCM with respect to it project ID which is shown in GCM Server and the second method is doing the same but it registers to web and the third method is to perform these two functions in background method in this way we declare the async_task class.
Register AsyncTask for Web
The print method is basically we declare when we receive the message from GCM and set up by its own style. The second method is,
Register Device To WebServer
Now we make a method for register devices to the web servers.
Summary
In the next article we will set up more settings and the next article is the last article of GCM.