【问题标题】:How to stop an application from being launched from notification panel when any button clicked on it?单击任何按钮时如何阻止应用程序从通知面板启动?
【发布时间】:2014-12-29 14:24:11
【问题描述】:

我有一个带有两个按钮的通知面板。当我单击任一按钮时,最小化的应用程序正在打开/恢复。

  public void setListeners(RemoteViews view){
    Intent stopNotify = new Intent(parent,HelperActivity.class);
    stopNotify.putExtra("DO", "stop");
    PendingIntent btn1 = PendingIntent.getActivity(parent, 0, stopNotify, 0);
    view.setOnClickPendingIntent(R.id.notifyStopButton, btn1); 

    Intent pauseUpload = new Intent(parent,HelperActivity.class);
    pauseUpload.putExtra("DO", "pause");    
    PendingIntent btn2 = PendingIntent.getActivity(parent, 1, pauseUpload, 0);
    view.setOnClickPendingIntent(R.id.uploadPauseButton, btn2); 
   }

我希望应用程序本身保持最小化。我错过了什么吗?

是否需要为 pendingIntent 添加 pass 任何参数?

提前致谢!!

【问题讨论】:

    标签: android android-notifications android-notification-bar


    【解决方案1】:

    我希望应用程序本身保持最小化。我错过了什么吗?

    您正在向那些视图提供PendingIntents,这些视图将在单击这些视图时启动活动。

    如果您不想这样做,请不要提供将启动活动的PendingIntents

    【讨论】:

      猜你喜欢
      • 2014-12-16
      • 1970-01-01
      • 2016-04-19
      • 1970-01-01
      • 2018-11-22
      • 2021-07-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多