Demo entry 6662164

JPush SDK Demo

   

Submitted by zhou on Nov 25, 2017 at 01:31
Language: Java. Code size: 1.0 kB.

publicclassMainActivityextendsActivity{
privateJPluginPlatformInterfacepHuaweiPushInterface;
@Override
publicvoidonCreate(BundlesavedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
initView();
registerMessageReceiver();//usedforreceivemsg
pHuaweiPushInterface=newJPluginPlatformInterface(this.getApplicationContext());
}
@Override
publicvoidonStart(){
super.onStart();
//引用当前Activity,并且如果HMSSDK没有初始化则会初始化HMSSDK.
pHuaweiPushInterface.onStart(this);
}
@Override
publicvoidonStop(){
super.onStop();
//清空对当前Activity的引用.
pHuaweiPushInterface.onStop(this);
}
@Override
protectedvoidonActivityResult(intrequestCode,intresultCode,Intentdata){
super.onActivityResult(requestCode,resultCode,data);
//经过用户操作解决完错误之后,返回让HMS重新初始化..JPush中调用HMSSDK
//解决错误的接口传入的requestCode为10001,开发者调用时请注意不要同样
//使用10001
if(requestCode==JPluginPlatformInterface.JPLUGIN_REQUEST_CODE){
pHuaweiPushInterface.onActivityResult(this,requestCode,resultCode,data);
}
}
}
}

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).