我正在尝试启动一项服务,但我一直在 logcat 输出中看到以下消息,这让我怀疑事情是否真的有效:
W/ContextImpl( 1506): Calling a method in the system process without a qualified user:
android.app.ContextImpl.startService:1479
android.content.ContextWrapper.startService:494
myapp.startService:765
myapp.onStart:386 a
ndroid.app.Instrumentation.callActivityOnStart:1171
Run Code Online (Sandbox Code Playgroud)
我的应用程序是平台构建的一部分并安装在系统目录中。现在我有这个活动的代码(从 onStart 启动服务):
public class MyAppNotification extends Activity {
@Override
protected void onStart() {
super.onStart();
...
MyAppService.startService(MyAppNotification.this);
}
}
Run Code Online (Sandbox Code Playgroud)
该服务然后提供此功能:
public class MyAppService extends Service {
...
public static void startService(Context context) {
Intent intent = new Intent(context, MyAppService.class);
context.startService(intent);
}
}
Run Code Online (Sandbox Code Playgroud)
我会提到之前该服务是由广播接收器启动的,但我想切换到手动启动它。
最后,这是一个没有正确处理上下文的问题吗?
| 归档时间: |
|
| 查看次数: |
507 次 |
| 最近记录: |