Android Baidu Cloud Push

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.