相关疑难解决方法(0)

android从服务开始活动

安卓:

public class LocationService extends Service {

@Override
    public void onStart(Intent intent, int startId) {
        super.onStart(intent, startId);
        startActivity(new Intent(this, activity.class));
    }
}
Run Code Online (Sandbox Code Playgroud)

我推出了这项服务 Activity

Activity如果条件满足启动

startService(new Intent(WozzonActivity.this, LocationService.class));
Run Code Online (Sandbox Code Playgroud)

从我LocationService上面提到的无法启动Activity,我怎样才能获得当前Activity在服务类中运行的上下文?

android android-service android-activity

139
推荐指数
5
解决办法
20万
查看次数