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 reception handler.

Add three 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 setting the reception handler (BroadcastReceiver). KiiPushBroadcastReceiver will be the name of the class that you will implement to receive the push notifications.

  • The third section is for setting the JPush App Key. Replace the "YOURJPUSHAPP_KEY" with the JPush App Key.

Change the package name "com.example.pushtest" if needed. There are seven places where you need to modify the name.
Also, do not forget to update your JPush's AppKey.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.kii.sample.push"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="19" />

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


    <!-- *** add following lines *** -->
    <permission android:name="com.kii.sample.push.permission.JPUSH_MESSAGE" android:protectionLevel="signature" />
    <uses-permission android:name="com.kii.sample.push.permission.JPUSH_MESSAGE" />
    <uses-permission android:name="android.permission.RECEIVE_USER_PRESENT" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_SETTINGS" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
    <!-- *** 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.kii.sample.push.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 *** -->
        <activity
            android:name="cn.jpush.android.ui.PushActivity"
            android:configChanges="orientation|keyboardHidden"
            android:exported="false">
            <intent-filter>
                <action android:name="cn.jpush.android.ui.PushActivity" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="com.kii.sample.push" />
            </intent-filter>
        </activity>

        <service
            android:name="cn.jpush.android.service.DownloadService"
            android:enabled="true"
            android:exported="false" >
        </service>

        <service android:name="cn.jpush.android.service.PushService" android:enabled="true" android:exported="false" >
            <intent-filter>
                <action android:name="cn.jpush.android.intent.REGISTER" />
                <action android:name="cn.jpush.android.intent.REPORT" />
                <action android:name="cn.jpush.android.intent.PushService" />
                <action android:name="cn.jpush.android.intent.PUSH_TIME" />
            </intent-filter>
        </service>

         <service
             android:name="cn.jpush.android.service.DaemonService"
             android:enabled="true"
             android:exported="true">
             <intent-filter >
                 <action android:name="cn.jpush.android.intent.DaemonService" />
                 <category android:name="com.kii.sample.push"/>
             </intent-filter>
         </service>

        <receiver android:name="cn.jpush.android.service.PushReceiver" android:enabled="true" android:exported="false" >
            <intent-filter android:priority="1000" >
                <action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED_PROXY" />
                <category android:name="com.kii.sample.push" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.USER_PRESENT" />
                <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.PACKAGE_ADDED" />
                <action android:name="android.intent.action.PACKAGE_REMOVED" />
                <data android:scheme="package" />
            </intent-filter>
        </receiver>

        <receiver android:name="cn.jpush.android.service.AlarmReceiver" />

        <receiver android:name="com.kii.sample.push.KiiPushBroadcastReceiver" android:enabled="true" >
            <intent-filter>
                <!-- Receives the actual messages. -->
                <action android:name="cn.jpush.android.intent.REGISTRATION" />
                <action android:name="cn.jpush.android.intent.MESSAGE_RECEIVED" />
                <action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED" />
                <action android:name="cn.jpush.android.intent.NOTIFICATION_OPENED" />
                <category android:name="com.kii.sample.push" />
            </intent-filter>
        </receiver>
        <!-- *** up to this point *** -->


        <!-- *** add following lines *** -->
        <meta-data android:name="JPUSH_CHANNEL" android:value="developer-default" />
        <meta-data android:name="JPUSH_APPKEY" android:value="YOUR_JPUSH_APP_KEY" />
        <!-- *** up to this point *** -->


    </application>
</manifest>

Note: The above Manifest file includes the permissions and services that are recommended by JPush. Some of them are not used by Kii Cloud. Read the JPush documentation for more details.

Next we will start the implementation: Implement Your Application.


<< Configure the Build Environment Implement Your Application >>