我在Service中定义了一个方法,在方法中
Intent intent = new Intent(getApplicationContext(), SmokeActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
想要开启一个Activity,这是这个Activity的设置
<activity
android:name="com.aa.safe.safehei.activities.SmokeActivity"
android:launchMode="singleInstance"
android:theme="@style/MyTheme">
</activity>
我如果在这个Activity相同亲和性的Activity的窗口之上打开,那么它就会立即被调用,但是如果我返回到桌面后再使用服务中的方法开启这个Activity,他的响应效率就很差劲,延迟3-5秒都有可能.这是为什么?
Are you monitoring the Home button to start the Activity? , there will indeed be a 5s delay. You can solve this problem with the following code
onReceive()
中调用startActivity()
It may have something to do with your opening method, because you opened it in SingleInstance Mode, and whether your Service is a remote Service!
Change your launchMode to default and try it
Can you post the code of your Service and SmokeActivity? From your description, I can’t confirm which part has the problem