在执行AIDL 通信的时候,我们需要绑定service 报错:
Unable to start service Intent { act=xx.xx.xx } U=0: not found
后使用intent.component解决
private fun startRemoteService() {
Log.d(TAG, "---------------------------startRemoteService: ")
val intent = Intent()
intent.component = ComponentName("aaaaaaaaaaa", "sssssssssssss.RemoteService")
intent.action = "xxxxxxxxxxxxxx"
bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE)
}
ComponentName pkg:要启动的进程名称 cls:要启动的service对象
public ComponentName(@NonNull String pkg, @NonNull String cls) {
if (pkg == null) throw new NullPointerException("package name is null");
if (cls == null) throw new NullPointerException("class name is null");
mPackage = pkg;
mClass = cls;
}
|