当使用AIDL去bindService时,这时的代码一般是
private static final String SERVICE_CLASS_NAME = "com.segway.robot.webmonitor.webmonitorservice.WebMonitorService";
private static final String SERVICE_PACKAGE_NAME = "com.segway.robot.webmonitor";
Intent intent = new Intent();
intent.setAction(SERVICE_CLASS_NAME);
intent.setPackage(SERVICE_PACKAGE_NAME);
intent.setClassName(SERVICE_PACKAGE_NAME, SERVICE_CLASS_NAME);
boolean index = MainActivity.this.bindService(intent, connection, Context.BIND_AUTO_CREATE);
Log.e(TAG, "bind service success? " + index);
这时就要注意PackageName。如果你的目录是
setPackage应该是
com.segway.robot.webmonitor
,而不是services所在的包com.segway.robot.webmonitor.webmonitorservice