Http://developer.baidu.com/wiki/index.php?title=docs/cplat/push/sdk/clientsdk.
publicclassextends frontiaapplication { @Override public void onCreate () { // Super. OnCreate (); }}
This application embodies the entire app life cycle, and if you do not initialize it, the initialization in manifest is not minimal. You have to add the Android:name label. The code would look like this:
<application android:name= "com.baidu.push.example.DemoApplication" android:icon= "@drawable/ic_ Launcher " android:label=" @string/app_name ">
When the application, the OnCreate function in this one must add such a sentence! Code so:
Frontiaapplication.initfrontiaapplication (Context context)
When in a when, the authority is what thing, have the ability to play, must add, manifest this file, must add, code will crawl down:
<uses-permission android:name= "Android.permission.INTERNET"/> <uses-permission android:name= " Android.permission.READ_PHONE_STATE "/> <uses-permission android:name=" android.permission.ACCESS_NETWORK_ State "/> <uses-permission android:name=" Android.permission.RECEIVE_BOOT_COMPLETED "/> < Uses-permission android:name= "Android.permission.WRITE_SETTINGS"/> <uses-permission android:name= " Android.permission.VIBRATE "/> <uses-permission android:name=" Android.permission.WRITE_EXTERNAL_STORAGE "/ > <uses-permission android:name= "Android.permission.DISABLE_KEY GUARD"/> <uses-permission android:name= "Android.permission.ACCESS_COARSE_LOCATION"/> <uses-permission android:name= "android.permission.ACCESS_ Wifi_state "/>
The above is the code, with these code, security of the exception quickly go home, from this logcat file no longer see him.
When in a, a reciver code to register, more recipients, push this ghost, please go to the bowl. What about the code, look up to your head.
<!--push service client--<receiver android:name= "Your.package.MyPushMessageReceiver" > < Intent-filter> <!--receive push messages--<action android:name= "Com.baidu.android.pushservice.action.MESSAGE"/ > <!--receive the return results of BIND, settags, and other method--<action Android:name= " Com.baidu.android.pushservice.action.RECEIVE "/> <!--optional. Accept notification Click events, and notifications custom content-<action android:name= "Com.baidu.android.pushservice.action.notification.CLICK"/> </intent-filter> </receiver>
When in a, a service workers object is not small, I do the letter Oh, continue to check the information, manifest list and sent in great need, this is the source:
<!--push service start--<!--to receive system messages to ensure pushservice uptime--<receiver android:name= " Com.baidu.android.pushservice.MyPushServiceReceiver "android:process= ": Bdservice_v1" > <intent-filter> <action android:name= "Android.intent.action.BOOT_COMPLETED"/> <action android:name= "Android.net.conn.CONNECTIVITY_CHANGE"/> <action android:name= " Com.baidu.android.pushservice.action.notification.SHOW "/> <action android:name=" Com.baidu.android.pushservice.action.media.CLICK "/> </intent-filter> </receiver> <!-- The push service receives various requests sent by the client-<!--Note: Registrationreceiver in 2.1. 1 and previous versions have spelling errors, for Registratonreceiver, use the new version of the SDK when you change to the following code--<receiver android:name= "Com.baidu.android.pushservice.RegistrationReceiver"android:process= ": Bdservice_v1" > <intent-filter> <action android:name= "Com.baidu.android.pushservice.action.METHOD"/ > <action android:name= "Com.baidu.android.pushservice.action.BIND_SYNC"/> </intent-filter> < intent-filter> <action android:name= "Android.intent.action.PACKAGE_REMOVED"/> <data android:scheme= " Package "/> </intent-filter> </receiver> <!--Push Service--<service Android:name = "Com.baidu.android.pushservice.PushService"android:exported= "true" android:process= "Bdservice_v1"/>
Android Baidu Cloud Push