Android点击通知栏返回正在运行的Activity
16lz
2022-01-25
private static int App_Notification_ID_BASE = 911; private static PendingIntent appDIndent; private static NotificationManager appMange; private static Notification appNF;
/** * 在Activity onCreate 中调用此方法 * @param paramContext * @param paramClass */ public void startAppNotification(Context paramContext, Class<?> paramClass) { if (appMange == null) { appMange = (NotificationManager)getSystemService("notification"); Intent localIntent = new Intent(this, paramClass); localIntent.setAction("android.intent.action.MAIN"); localIntent.addCategory("android.intent.category.LAUNCHER"); localIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK| Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); appDIndent = PendingIntent.getActivity(paramContext, 0, localIntent, 134217728); appNF = new Notification(); appNF.icon = 2130837545; appNF.tickerText = getResources().getString(2131099648); appNF.defaults = (0x1 | appNF.defaults); //声音提醒 appNF.flags = FLAG_ONGOING_EVENT ; //设置清除不掉 RemoteViews localRemoteViews = new RemoteViews(getPackageName(), 2130903046); appNF.contentView = localRemoteViews; appNF.contentIntent = appDIndent; appMange.notify(App_Notification_ID_BASE, appNF); } }
startAppNotification(getApplicationContext(), WelcomeActivity.class);
注意WelcomeActivity的android:launchMode要是标准模式
更多相关文章
- Android里面WebView加载HTML里面点击按钮调我Android方法
- Android笔记 SystemUI
- android facebook authorize 时禁止调用facebook app
- java.util.ConcurrentModificationException ArrayList
- android执行Linux命令
- android录音和得到音量
- android wpa_supplicant 流程分析
- Android关于OnTouch 和OnClick同时调用冲突的解决方案
- Android与Javascript交互示例(一)