写好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);

 

 

 

相关文章:

  • 2022-12-23
  • 2021-11-19
  • 2022-12-23
  • 2022-12-23
  • 2021-11-05
  • 2022-12-23
  • 2022-12-23
  • 2022-01-22
猜你喜欢
  • 2022-12-23
  • 2021-08-05
  • 2021-12-05
  • 2022-02-05
  • 2022-12-23
  • 2021-10-05
  • 2022-12-23
相关资源
相似解决方案