Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/190.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 单击“通知时转到片段”_Android_Android Fragments_Android Notifications - Fatal编程技术网

Android 单击“通知时转到片段”

Android 单击“通知时转到片段”,android,android-fragments,android-notifications,Android,Android Fragments,Android Notifications,在我的项目中,我使用的是导航抽屉方法。所以我在java类中使用片段。我使用通知管理器。当我收到通知时,我必须点击它才能进入通知类。它不会进入片段页面。如果我使用活动,它将不得不进入活动类。若我使用一个片段,那个么它就不会对类进行片段化 代码: 收到通知后,立即前往您的活动,并致电您的愿望fragment@sohanshetty我所有的类都是碎片,因为我使用了导航抽屉。它不打算碎片化。我不能understand@sohanshetty可能吗?您必须在某个活动中初始化导航抽屉 Intent inte

在我的项目中,我使用的是导航抽屉方法。所以我在java类中使用片段。我使用通知管理器。当我收到通知时,我必须点击它才能进入通知类。它不会进入片段页面。如果我使用活动,它将不得不进入活动类。若我使用一个片段,那个么它就不会对类进行片段化

代码:


收到通知后,立即前往您的活动,并致电您的愿望fragment@sohanshetty我所有的类都是碎片,因为我使用了导航抽屉。它不打算碎片化。我不能understand@sohanshetty可能吗?您必须在某个活动中初始化导航抽屉
Intent intent = new Intent(this,Student_notification.class);
//intent.putExtra("open",1);
PendingIntent pIntent =PendingIntent.getActivity(this,0,intent,PendingIntent.FLAG_UPDATE_CURRENT);
Bitmap bigicon = BitmapFactory.decodeResource(getResources(), R.drawable.logo);

// Build notification
Notification noti = new Notification.Builder(this).setContentTitle(data.notititle).setContentText("HappySchool")
        .setLargeIcon(bigicon).setSmallIcon(R.drawable.logo).setContentIntent(pIntent)
        .setDefaults(Notification.DEFAULT_ALL).build();
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
// hide the notification after its selected
noti.flags |= Notification.FLAG_AUTO_CANCEL;
notificationManager.notify(Integer.parseInt(data.notificationid), noti);