Android 消息通知栏返回正在运行的Activity

来源:互联网 发布:淘宝要五星好评话术 编辑:程序博客网 时间:2024/06/11 03:06
NotificationManager barmanager=(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);Notification notice = new Notification(android.R.drawable.stat_notify_chat,                          "服务器发来信息了",System.currentTimeMillis());notice.flags=Notification.FLAG_AUTO_CANCEL;Intent appIntent = new Intent(Intent.ACTION_MAIN);appIntent.addCategory(Intent.CATEGORY_LAUNCHER);appIntent.setComponent(new ComponentName(this.getPackageName(),                        this.getPackageName() + "." + this.getLocalClassName()));appIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|                   Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);//关键的一步,设置启动模式PendingIntent contentIntent =PendingIntent.getActivity(this, 0,appIntent,0);notice.setLatestEventInfo(this,"通知","信息:"+msg, contentIntent);barmanager.notify(STATUS_BAR_ID,notice);

0 0
原创粉丝点击