相关疑难解决方法(0)

单击"通知"后打开应用程序

我的应用程序中有一个通知,其中包含以下代码:

//Notification Start

   notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

   int icon = R.drawable.n1; 
   CharSequence tickerText = "Call Blocker";
   long when = System.currentTimeMillis(); //now
   Notification notification = new Notification(icon, tickerText, when);
   Intent notificationIntent = new Intent(context, Main.class);
   PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);

   Context context = getApplicationContext();
   CharSequence title = "Call Blocker";
   text = "Calls will be blocked while driving";

   notification.setLatestEventInfo(context, title, text, contentIntent);

   notification.flags |= Notification.FLAG_ONGOING_EVENT;
   notification.flags |= Notification.FLAG_SHOW_LIGHTS;
   notificationManager.notify(1, notification);

}
Run Code Online (Sandbox Code Playgroud)

我的通知触发得非常好,但我的问题是,当我点击通知中心的通知时,它无法启动我的应用.

基本上,点击我的通知后没有任何反应!我应该怎么做,以便在点击我的通知后开始我的主要活动.谢谢.

notifications android

98
推荐指数
8
解决办法
21万
查看次数

标签 统计

android ×1

notifications ×1