Configure the Manifest File

We will configure the manifest file so as to add the necessary privileges and to set the class name of the push handler.

Add two sections marked with the <!-- *** add following lines *** --> and <!-- *** up to this point *** --> to your AndroidManifest.xml file.

  • The first section is to add the necessary privileges to receive push notifications. Add them if your AndroidManifest.xml file does not have them (android.permission.INTERNET is needed for the general Kii Cloud SDK features).

  • The second section is for making various configurations. The GCMReceiver is a class provided by Android. We will implement others (MyGcmListenerService, MyInstanceIDListenerService, and RegistrationIntentService) later.

Change the package name "com.example.pushtest" if needed. There are four places where you need to modify the name.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.pushtest" >

    <uses-permission android:name="android.permission.INTERNET" />

    <!-- *** add following lines *** -->
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <!-- *** up to this point *** -->


    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.pushtest.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>


        <!-- *** add following lines *** -->
        <receiver
            android:name="com.google.android.gms.gcm.GcmReceiver"
            android:exported="true"
            android:permission="com.google.android.c2dm.permission.SEND" >
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
                <category android:name="com.example.pushtest" />
            </intent-filter>
        </receiver>
        <service
            android:name="com.example.pushtest.MyGcmListenerService"
            android:exported="false" >
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            </intent-filter>
        </service>
        <service
            android:name="com.example.pushtest.MyInstanceIDListenerService"
            android:exported="false">
            <intent-filter>
                <action android:name="com.google.android.gms.iid.InstanceID"/>
            </intent-filter>
        </service>
        <service
            android:name="com.example.pushtest.RegistrationIntentService"
            android:exported="false">
        </service>
        <!-- *** up to this point *** -->


    </application>
</manifest>

This manifest file and the classes we are going to implement in the next step are taken from the GCM tutorial. They are slightly modified for Kii Cloud usage. You can find the original codes in the GitHub mentioned in the push notification tutorial.

Next, we will start the implementation: Implement Your Application.


<< Configure the Build Environment Implement Your Application >>