zoukankan      html  css  js  c++  java
  • Android 消息通知栏返回正在运行的Activity

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

  • 相关阅读:
    SPF(poj 1523) 割点入门
    从一个例子讲解拷贝构造函数与return
    还是引用
    引用的实质
    const
    三目运算符
    关于C语言链表的学习
    CS2013调试DLL
    fread与fwrite的自我理解
    可见字符与不可见字符
  • 原文地址:https://www.cnblogs.com/vegetate/p/9997250.html
Copyright © 2011-2022 走看看