Intent inte=new Intent();
ComponentName com=new ComponentName("com.kld","com.kld.LocSaveService");
inte.putExtra("notifylocsms", con);
inte.putExtra("locsms", con);
inte.setComponent(com);
LocNotify.this.startService(inte);
一般这样调用,会报错:
java.lang.SecurityException: Not allowed to start service Intent { cmp=com.kld/.LocSaveService (has extras) } without permission private to package
解决办法:
就是把那个被调用的服务属性:
android:exported="true"
就可以解决了。
GOOGLE公布了一些常见BUG的解决办法,请参考网站: