【问题标题】:ProgressBar preventing to open notification (Activity)ProgressBar 阻止打开通知(活动)
【发布时间】:2015-01-27 01:16:07
【问题描述】:

我有一个执行 HTTP 请求的应用程序,我会显示一个 ProgressBar,直到服务器收到响应。 ProgressBar 可防止用户单击应用程序上的任何位置,这很好。

当用户在 ProgressBar 运行时收到应用通知并单击它(尝试打开 Activity)时,就会出现问题。基本上,什么都不会发生,因为 ProgressBar 会阻塞一切,直到请求完成,然后它会返回启动它的 Activity。

然后,由于通知是使用 .setAutoCancel(true) 创建的,所以当用户单击它时它就消失了,我不知道如何恢复它或者在这种情况下最好做些什么来避免丢失它。

我想检查通知意图打开的活动的onCreate方法上是否有ProgressBar(isShowing),但是它可以显示在我的应用程序的许多不同流中,所以我想知道是否有更好的方法而不是检查所有这些。

【问题讨论】:

    标签: android android-activity android-pendingintent android-progressbar


    【解决方案1】:

    最终,事实证明它与 progressBar 无关,而是与我试图打开相同的活动这一事实有关。在待处理的项目中使用不同的请求代码解决了这个问题:

    ....
    Intent myIntent = new Intent(this, MyOtherActivity.class);
    PendingIntent contIntent = PendingIntent.getActivity(
            this, 
            (int)(System.currentTimeMillis()/1000), // This is a timestamp, so will be different each time
            myIntent, 
            0
    );
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-28
      • 2023-03-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多