跨app执行bindservice

在同一个app内,bindservice传入的intent一般通过class生成。例如Intent intent = new Intent(mContext, MyService.class);

但是在跨APP进行bindservice的时候,intent需要通过service的action以及Component来获得。例如:

Intent intent = new Intent("com.my.server.memserver");
intent.setComponent(new ComponentName("com.my.server.memserver", "com.my.server.memserver.MmemServer"));


同时需要注意的是,aidl文件的位置要和server的位置保持一致。
比如server端的aidl文件的位置是com.my.server目录下,那么在client端aidl文件的位置也要在这个目录下。否则就会出现找不到的问题出现
posted @ 2019-01-22 20:56  KKKEr  阅读(434)  评论(0编辑  收藏  举报