友盟推送快速集成,適用於新手

1.libs 文件夾合併到本地工程libs子目錄下,再在Eclipse裏面刷新一下工程。android

2.<manifest>標籤下:app

<uses-permission android:name="android.permission.INTERNET" /> 
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<!--【可選】若是須要設置前臺是否顯示通知,須要設置這個權限-->
<uses-permission android:name="android.permission.GET_TASKS" /> <!-- 可選 -->
<uses-permission android:name="android.permission.BROADCAST_PACKAGE_ADDED" />
<uses-permission android:name="android.permission.BROADCAST_PACKAGE_CHANGED" />
<uses-permission android:name="android.permission.BROADCAST_PACKAGE_INSTALL" />
<uses-permission android:name="android.permission.BROADCAST_PACKAGE_REPLACED" />
<uses-permission android:name="android.permission.RESTART_PACKAGES" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />;

3.<application>標籤下:函數

注意 spa

添加組件時須要將【應用包名】替換爲你本身應用的包名。.net

<receiver
    android:name="com.umeng.message.NotificationProxyBroadcastReceiver"
 android:process=":push"
    android:exported="false" >
</receiver>
<receiver
    android:name="com.umeng.message.SystemReceiver"
    android:process=":push" >
    <intent-filter>
        <action android:name="android.intent.action.BOOT_COMPLETED" />
    </intent-filter>
    <intent-filter>
        <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
    </intent-filter>
    <intent-filter>
        <action android:name="android.intent.action.PACKAGE_REMOVED" />
        <data android:scheme="package" />
    </intent-filter>
</receiver>
<receiver
    android:name="com.umeng.message.MessageReceiver"
    android:process=":push" >
    <intent-filter>
        <action android:name="org.agoo.android.intent.action.RECEIVE" />
    </intent-filter>
</receiver>
<receiver
    android:name="com.umeng.message.ElectionReceiver"
    android:process=":push" >
    <intent-filter>
        <action android:name="org.agoo.android.intent.action.ELECTION_RESULT_V4" />
        <category android:name="umeng" />
    </intent-filter>
</receiver>
<receiver
    android:name="com.umeng.message.RegistrationReceiver"
    android:exported="false" >
    <intent-filter>
        <action android:name="【應用包名】.intent.action.COMMAND" />
    </intent-filter>
</receiver>
<receiver android:name="com.umeng.message.BootBroadcastReceiver" >
    <intent-filter>
        <action android:name="android.intent.action.BOOT_COMPLETED" />
    </intent-filter>
</receiver>
    android:exported="true"
<intent-filter>
        <action android:name="【應用包名】.intent.action.START" />
    </intent-filter>
    <intent-filter>
        <action android:name="【應用包名】.intent.action.COCKROACH" />
    </intent-filter>
    <intent-filter>
        <action android:name="org.agoo.android.intent.action.PING_V4" />
    <category android:name="umeng" />
    </intent-filter>
</service>
<service android:name="com.umeng.message.UmengIntentService" 
    android:process=":push" />
<service 
    android:name="com.umeng.message.UmengMessageIntentReceiverService"
    android:process=":push" 
    android:exported="true" >
    <intent-filter>
        <action android:name="org.android.agoo.client.MessageReceiverService" />
    </intent-filter>
    <intent-filter>
        <action android:name="org.android.agoo.client.ElectionReceiverService" />
    </intent-filter>
</service>
<!-- V1.3.0添加的service,負責下載通知的資源 -->
<service android:name="com.umeng.message.UmengDownloadResourceService" />

4.<application>標籤下:code

<meta-data     android:name="UMENG_APPKEY"
               android:value="xxxxxxxxxxxxxxxxxxxxxxxxxxxx" > 
</meta-data>
 <meta-data    android:name="UMENG_MESSAGE_SECRET"
               android:value="xxxxxxxxxxxxxxxxxxxxxxxxxxxx" > 
</meta-data>

5.在應用的主Activity onCreate() 函數中開啓推送服務ip

PushAgent mPushAgent = PushAgent.getInstance(context); 
mPushAgent.enable();
相關文章
相關標籤/搜索