Stu*_*DTO 7 service android android-intent android-activity
我有一个Service
当一个函数给我true
时它将启动一个新的Activity
但它需要5秒...
我已经读过这个issue
,我在StackOverflow
这个例子中找到了"避免"这个bug.
Intent intent = new Intent(this, MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, 0);
try {
pendingIntent.send();
} catch (PendingIntent.CanceledException e) {
e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)
但遗憾的是它没有Activity
更快启动,我不需要处于初级状态(如果可能的话更好),但是我不想等待+5秒来启动新功能Activity
,你是否知道要避免这种情况?
我正在使用,PendingIntent
因为我发现那个人说它应该解决这个问题:
在没有5秒延迟的情况下按下HOME按钮后从服务启动一个活动
如果我按下back button
它会自动启动它,0延迟,但我正在按下它home button
.
小智 9
我无法在任何地方评论,所以我将这个类似问题的解决方案作为答案
经过多次挖掘,找出问题的原因.显然它不是一个错误,它是一个功能,它不允许Services或BroadcastReceivers在按下主页按钮后最多启动5秒的活动.没有简单的方法来克服这一点.
有关详情,请访问:https: //code.google.com/p/android/issues/detail?id = 4536
我用添加到正在运行的服务的窗口管理器的Window替换了活动.这不会造成任何延误.
归档时间: |
|
查看次数: |
1986 次 |
最近记录: |