是否有可能开始从服务的活动?如果是的话,我们如何才能做到这一点?
Is it possible to start an Activity from a Service? If yes, how can we achieve this?
android.app.Service
的后裔 android.app.Context
这样你就可以 startActivity
直接使用。但是,因为你开始这个你需要设置 FLAG_ACTIVITY_NEW_TASK
标志对意图的任何活动之外。
android.app.Service
is descendant of android.app.Context
so you can use startActivity
directly. However since you start this outside any activity you need to set FLAG_ACTIVITY_NEW_TASK
flag on the intent.
例如:
Intent i = new Intent();
i.setClass(this, MyActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);
其中,这
为您服务。
上一篇:如何导入Eclipse项目到Android的工作室呢?工作室、项目、Eclipse、Android
下一篇:ViewPager.setOffscreenPageLimit(0)按预期的方式不起作用不起作用、方式、ViewPager、setOffscreenPageLimit