今天在研究AIDL的时候,bindService服务端的service一直返回false,在网上查一直说的什么Context问题,发现跟自己的情况不一样,仔细研究了下,发现一个大坑。
启动service的时候
getApplicationContext().startService(new Intent(getApplicationContext(),BookService.class));
调试发现返回值 componentName
没错,package是 com.example.pang.aidlserviver 而不是我们设想的com.example.pang.aidlserviver.service.ssss,之前一直以为填的是service所在的包名,无语。怀疑package参数指的是service端的package,故而修改service的package为aidlserviver2: