android 活动说明,Android – 如何发送GCM推送通知以及要加载哪些活动的说明?
更新:
給Eran以JSON為榮,我只想詳細(xì)說明.
您可以使用數(shù)據(jù)鍵添加其他參數(shù):
{
"registration_ids" : ["APA91bHun4MxP5egoKMwt2KZFBaFUH-1RYqx..."],"data": {
"stuff": "100","more": "abc"
},}
然后使用intent.getExtras().getString(“stuff”)以相同的方式訪問.
然后在你的generateNotifcation()中:
private static void generateNotification(Context context,String message) {
NotificationManager notificationManager = (NotificationManager)
context.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(R.drawable.ic_launcher,message,when);
String title = "...";
//get id from json here and decide which activity to go to...
Intent notificationIntent = new Intent(context,someClass.class);
notificationIntent.putExtra("message",message);
PendingIntent intent = PendingIntent.getActivity(context,notificationIntent,PendingIntent.FLAG_UPDATE_CURRENT);
notification.setLatestEventInfo(context,title,intent);
notification.defaults|=Notification.DEFAULT_VIBRATE;
notificationManager.notify(0,notification);
}
總結(jié)
以上是生活随笔為你收集整理的android 活动说明,Android – 如何发送GCM推送通知以及要加载哪些活动的说明?的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
 
                            
                        - 上一篇: html弹出div提示自动关闭,html
- 下一篇: html页面选择指定条件在下方显示,如何
