1. To the aurora to push the official website registered users.
2. Create an app to apply the app key according to the package name, note that a package name corresponds to a appkey, and if not, the function cannot be implemented.
3. Download the SDK on the official website with the guide.
4. The first is a variety of paste copy, be careful not to miss out
5. Then configure the Manifest.xml file
1) At the beginning, the first permission was forgotten by me.
2) In addition to the required part of the Myreceiver also copy the part of the
3) Note that the name of the modified package and the last Appkey, but the official website provided by the example has been modified to directly use
<permission android:name= "Com.zhangkong.module.permission.JPUSH_MESSAGE" android:protectionlevel= "sig Nature "/> <!--Required Some system-required permissions, such as access to the network, etc.--<uses-permission android:name=" Com.zhangkong.module.perm Ission. Jpush_message "/> <uses-permission android:name=" Android.permission.RECEIVE_USER_PRESENT "/> <uses-perm Ission android:name= "Android.permission.INTERNET"/> <uses-permission android:name= "android.permission.WAKE_ LOCK "/> <uses-permission android:name=" Android.permission.READ_PHONE_STATE "/> <uses-permission Android : Name= "Android.permission.WRITE_EXTERNAL_STORAGE"/> <uses-permission android:name= "Android.permission.READ _external_storage "/> <uses-permission android:name=" Android.permission.WRITE_SETTINGS "/> <uses-permis Sion 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.ACCESS_WIFI_STATE "/> <uses-permission android:name=" android.permission.SYSTEM_ALERT_ Window "/> <!--Optional for location--<uses-permission android:name=" Android.permission.ACC Ess_coarse_location "/> <uses-permission android:name=" Android.permission.CHANGE_WIFI_STATE "/> <uses-p Ermission android:name= "Android.permission.ACCESS_FINE_LOCATION"/> <uses-permission android:name= " Android.permission.ACCESS_LOCATION_EXTRA_COMMANDS "/> <uses-permission android:name=" Android.permission.CHANGE_NETWORK_STATE "/> <application android:allowbackup=" true "Android: icon= "@drawable/ic_launcher" android:label= "@string/app_name" android:theme= "@style/apptheme" Androi D:name= "Com.zhangkong.module.MyApplication" > <activity android:Name= ". 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> <activity Android:name= ". Interface1 "android:label=" @string/app_name "> </activity> <activity Android:name= ". Interface3 "android:label=" @string/app_name "> </activity> <!--Rich Push core features since 2.0.6--> <activity Androi D:name= "cn.jpush.android.ui.PopWinActivity" android:theme= "@style/mydialogstyle" android:exported= "f Alse "> </activity> <!--Required SDK Core features--<activity Android:name= "cn.jpush.android.ui.PushActivity" android:configchanges= "Orientation|keyboardhidden" Android:theme= "@android: Style/theme.notitlebar" android:exported= "false" > <intent-filter& Gt <action android:name= "cn.jpush.android.ui.PushActivity"/> <category android:name= "android.intent. Category. DEFAULT "/> <category android:name=" Com.zhangkong.module "/> </intent-filter> </activity> <!--Required SDK Core Features--<service android:name= "cn.jpush.android. Service. Downloadservice "android:enabled=" true "android:exported=" false "> </service> <!--Required SDK Core Features--<!--configurable android:process parameters put Pushservice in other processes--<serv Ice android:name= "Cn.jpush.android.service.PushService" android:enabled= "true" Android:exported= "false" > <intent-filter> <action android:name= "cn.jpush.android.i Ntent. REGISTER "/> <action android:name=" Cn.jpush.android.intent.REPORT "/> <action an Droid:name= "Cn.jpush.android.intent.PushService"/> <action android:name= "Cn.jpush.android.intent.PUS H_time "/> </intent-filter> </service> <!--since 1.8.0 option is available. The ability to pull together Jpush services for different applications in the same device. -<!--If you do not enable this feature to remove the component, it will not pull up other apps or be pulled by other apps-<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:na Me= "Com.zhangkong.module"/> </intent-filter> </service> <!--ReQuired SDK Core Features--<receiver android:name= "Cn.jpush.android.service.PushReceiver" Androi D:enabled= "true" android:exported= "false" > <intent-filter android:priority= "$" > <action android:name= "Cn.jpush.android.intent.NOTIFICATION_RECEIVED_PROXY"/> <!--Required Show notification bar--> ; <category android:name= "Com.zhangkong.module"/> </intent-filter> <intent-filter> <action android:name= "Android.intent.action.USER_PRESENT"/> <action android:name= " Android.net.conn.CONNECTIVITY_CHANGE "/> </intent-filter> <!--Optional-- <intent-filter> <action android:name= "Android.intent.action.PACKAGE_ADDED"/> <action android:name= "Android.intent.action.PACKAGE_REMOVED"/> <data android:scheme= "package"/& Gt </intent-filter> </receiver> <!--Required SDK Core features--<RECEIV Er android:name= "Cn.jpush.android.service.AlarmReceiver" android:exported= "false"/> <!--User defined . For test only user-defined broadcast receiver--<receiver android:name= "Com.zhangkong.module.MyReceiver" Android:exported= "false" android:enabled= "true" > <intent-filter> <action Android:name= "Cn.jpush.android.intent.REGISTRATION"/> <!--Required User Registration SDK intent--> <action Android:name= "Cn.jpush.android.intent.UNREGISTRATION"/> <action android:name= "Cn.jpush.android.int Ent. Message_received "/> <!--Required user receives intent--> <action android:name= for SDK messages" cn.jpush.android.i Ntent. Notification_received "/> <!--Required user receives the SDK notification bar information intent--> <action android:name=" cn.jpush.a Ndroid.inteNt. Notification_opened "/> <!--Required users to open the intent--> <action android:name= of the custom notification bar Cn.jpush.andro Id.intent.ACTION_RICHPUSH_CALLBACK "/> <!--Optional User accepts the rich Push Javascript callback function intent--> <ac tion android:name= "Cn.jpush.android.intent.CONNECTION"/><!--receive network changes connect/disconnect since 1.6.3-<cat Egory android:name= "Com.zhangkong.module"/> </intent-filter> </receiver> <!--Required. Enable it can get statistics data with channel-to-<meta-data android:name= "Jpush_channel" android:value= "Developer-default"/> <meta-data android:name= "Jpush_appkey" android:value= "Ea3709c8dac9957b7aa36ba1"/> & lt;! --</> value from the developer platform Appkey--> </application>
6. Need to copy over three classes
7. The other two do not need to change, the key in the Myreceiver class, and in their own mainactivity to add the corresponding code
Send msg to mainactivityprivate void Processcustommessage (context context, bundle bundle) {if ( Mainactivity.isforeground) {String message = bundle.getstring (jpushinterface.extra_message); String Extras = bundle.getstring (Jpushinterface.extra_extra); Intent msgintent = new Intent (mainactivity.message_ received_action);//The activity should be changed Msgintent.putextra (Mainactivity.key_message, MESSAGE);//Notice that the activity is changed to its own main interface, You need to define if (! Exampleutil.isempty (Extras)) {try {jsonobject Extrajson = new Jsonobject (extras); if (null! = Extrajson && Extrajs On.length () > 0) {msgintent.putextra (Mainactivity.key_extras, EXTRAS);//Here's the same as}} catch (Jsonexception e) {}} Context.sendbroadcast (msgintent);}}
8. In their own mainactivity add code, you can directly from the example mainactivity copied over, the red part is my own add, do not always receive push, from the internet to see an example said need to add.
public class Mainactivity extends Activity {private Button button1;private button < /pre>
public static Boolean isforeground = False;private EditText msgtext; @Overridepublic void OnCreate (Bundle savedinst Ancestate) {super.oncreate (savedinstancestate); Setcontentview (R.layout.activity_main); Jpushinterface.init (this); Registermessagereceiver (); Used for receive msginit (); button1 = (Button) This.findviewbyid (r.id.button1); button3 = (Button) This.findviewbyid ( R.id.button3); Button1.setonclicklistener (new Onclicklistener () {public void OnClick (View v) {Intent Intent = new Intent ( Mainactivity.this, Interface1.class); startactivity (intent);}); Button3.setonclicklistener (New Onclicklistener () {public void OnClick (View v) {Intent Intent = new Intent ( Mainactivity.this, Interface3.class); startactivity (intent);}}); private void Init () {Jpushinterface.init (Getapplicationcontext ());} @Overrideprotected void Onresume () {isforeground = True;super.onresume (); Jpushinterface.onresume (this);//This sentence is added by yourself} @Overrideprotected void OnPause () {isforeground = False;super.onpause (); Jpushinterface.OnPause (this);} @Overrideprotected void OnDestroy () {unregisterreceiver (mmessagereceiver); Super.ondestroy ();} public static final String key_title = "TITLE";p ublic static final String key_message = "MESSAGE";p ublic static final Stri ng Key_extras = "EXTRAS";p rivate messagereceiver mmessagereceiver;public static final String message_received_action = "C Om.zhangkong.module.MESSAGE_RECEIVED_ACTION ";//Remember to modify the package name public void Registermessagereceiver () {mmessagereceiver = new Messagereceiver (); intentfilter filter = new Intentfilter (); filter.setpriority (intentfilter.system_high_priority); Filter.addaction (message_received_action); Registerreceiver (mmessagereceiver, filter);} public class Messagereceiver extends Broadcastreceiver {@Overridepublic void OnReceive (context context, Intent Intent) {i F (Message_received_action.equals (Intent.getaction ())) {String Messge = Intent.getstringextra (key_message); String Extras = Intent.getstringextra (Key_extras); StringBuilder showmsg = new StringBuilder (); Showmsg.appenD (key_message + ":" + messge + "\ n"); Exampleutil.isempty (Extras)) {Showmsg.append (Key_extras + ":" + extras + "\ n");} Setcostommsg (Showmsg.tostring ());}}} private void Setcostommsg (String msg) {if (null! = Msgtext) {msgtext.settext (msg); Msgtext.setvisibility ( Android.view.View.VISIBLE); }}}9. Then all OK, to the official website to push a message to try. after clicking on the message there is a default display interface, do not know why and I preset the wrong, next time look, solve and then write it!
Android integrated Aurora Push SDK Basic Service