按Notification 回到正在运行的activity

简介: 写好Notification , 按Home回到主界面,再按通知栏的消息(Notification), 回到退出之前正在运行的Acticity .     在代码中加入两行代码作为声名即可。 :                                  Intent notificationIntent = new Intent(this,this.

  写好Notification , 按Home回到主界面,再按通知栏的消息(Notification), 回到退出之前正在运行的Acticity .

    在代码中加入两行代码作为声名即可。 :

                 
                 Intent notificationIntent = new Intent(this,this.getClass()); 

                /* */
                notificationIntent.setAction(Intent.ACTION_MAIN);
                notificationIntent.addCategory(Intent.CATEGORY_LAUNCHER);
                 

                PendingIntent contentIntent = PendingIntent.getActivity(this.context, 0, notificationIntent,PendingIntent.FLAG_UPDATE_CURRENT);
                notification.setLatestEventInfo(context, title, text, contentIntent);        
                mNotificationManager.notify(NOTIFICATION_SERVICE_ID,notification);

 

 

 

目录
相关文章
|
4月前
启动前台Activity
启动前台Activity
35 1
|
4月前
fragment启动activity方法
fragment启动activity方法
44 1
|
Android开发
Android 后台限制启动Service、Activity与Notification、PendingIntent浅析
Android 后台限制启动Service、Activity与Notification、PendingIntent浅析
2586 0
Android 后台限制启动Service、Activity与Notification、PendingIntent浅析
Activity的四种状态
一个Activity实质上有四种状态:运行,暂停,停止,销毁
141 0
|
Android开发
Activity三种状态
Activity三种状态
454 0
|
Android开发
Android中 如何在本Activity页面退出后回到首页或者指定的Activity入口
Android中 如何在本Activity页面退出后回到首页或者指定的Activity入口
1461 0
|
缓存 前端开发 Java
Activity显示到Window的过程
写在前面的话 今天看到一个新闻,关于虾米音乐的程序员写的注释。 好像图都绿了,突然间想起在我曾经老大的影响下,我的Log输出已经变成了fxxk。
975 0