两种方法都无法绑定到远程服务?也就无法调用ServiceConnection这个接口,导致报空指针异常
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initView();
//启动时绑定服务
bindMyService();
}
private void bindMyService() {
Intent intent=new Intent();
// intent.setComponent(newComponentName("com.example.njh.aidltest",
"com.example.njh.aidltest.MyAidlService"));
intent.setAction("com.example.njh.AIDL_SERVICE");
bindService(intent, conn, Context.BIND_AUTO_CREATE);
Log.e("TAG", "333");
}