Android从服务开始活动Android:public class LocationService extends Service {@Override
public void onStart(Intent intent, int startId) {
super.onStart(intent, startId);
startActivity(new Intent(this, activity.class));
}}我是从Activity在……里面Activity如果条件满足启动startService(new Intent(WozzonActivity.this, LocationService.class));从我的LocationService上述无法发射Activity,如何获得当前运行的上下文?Activity在服务班?
3 回答
慕村225694
TA贡献1880条经验 获得超4个赞
Intent dialogIntent = new Intent(this, MyActivity.class);dialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);startActivity(dialogIntent);
繁星淼淼
TA贡献1775条经验 获得超11个赞
Intent dialogIntent = new Intent(this, myActivity.class); dialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); this.startActivity(dialogIntent);
public static Service myService;myService = this;new SubService(myService); Intent dialogIntent = new Intent(myService, myActivity.class); dialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);myService.startActivity(dialogIntent);
nullpointerexception
.
收到一只叮咚
TA贡献1821条经验 获得超4个赞
Intent intent = new Intent(storedActivity, MyActivity.class); intent.setAction(Intent.ACTION_VIEW); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); storedActivity.startActivity(intent);
storedActivity.startActivity(intent);
- 3 回答
- 0 关注
- 422 浏览
添加回答
举报
0/150
提交
取消