相关疑难解决方法(0)

如何在android中按下通知时打开片段页面

我在通知栏中按通知时试图打开一个片段.我的app结构是:

  • 带导航抽屉菜单的基本活动
  • 从菜单打开的一些片段

    b.setOnClickListener(new OnClickListener() {
    
            @SuppressWarnings({ "deprecation", "static-access" })
            public void onClick(View v) {
    
            w_nm=(NotificationManager) getActivity().getSystemService(getActivity().NOTIFICATION_SERVICE);
    
             Notification notify=new Notification(R.drawable.notnificationlogo,waternoti,System.currentTimeMillis());
    
             Intent notificationIntent = new Intent(getActivity(), Abc.class);
    
    
    
             PendingIntent pending=PendingIntent.getActivity(getActivity(), 0,notificationIntent, 0);
    
    
             notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
                     | Intent.FLAG_ACTIVITY_SINGLE_TOP );
    
            notify.flags = Notification.DEFAULT_LIGHTS | Notification.FLAG_AUTO_CANCEL;
    
               notify.setLatestEventInfo(getActivity(),waternoti,waternoti1, pending);
    
             w_nm.notify(0, notify);
    
    Run Code Online (Sandbox Code Playgroud)

谁能告诉我如何链接下一个片段页面(当前代码在扩展片段的类中)

android android-notifications android-fragments android-pendingintent

31
推荐指数
3
解决办法
4万
查看次数