关于Aidl无法启动server
aidl 网上文章很多 按照demo 写一遍会更好 本文主要讲述 很多人按照demo写
bindservice的过程 由于高版本的Android 限制了隐式Intent启动Service,需要指定包名和类名。
按照很多demo的写法
Intent intent = new Intent(); intent.setAction("com.shameit.server.IMyAidlInterface"); intent.setPackage("com.shameit.aidl");
通过Action启动指定注册的Service android6.0之后是无效的了
正确写法
Intent intent = new Intent();
intent.setComponent(new ComponentName("com.shameit.server", "com.shameit.server.MyService"));
Intent.setComponent(Component(packageName,className));
第一个参数packageName是需要启动的service所在的包名,第二个参数className是service的类完整名称。
service正常启动了。

1005

被折叠的 条评论
为什么被折叠?



