manifest中:代碼中:IntentFilterintentFilter;BootCompleteReceiverbootCompleteReceiver;@OverrideprotectedvoidonCreate(BundlesavedInstanceState){super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);intentFilter=newIntentFilter();intentFilter.addAction("android.intent.action.BOOT_COMPLETED");bootCompleteReceiver=newBootCompleteReceiver();registerReceiver(bootCompleteReceiver,intentFilter);}都寫了BootCompleteReceiverclassBootCompleteReceiverextendsBroadcastReceiver{@OverridepublicvoidonReceive(Contextcontext,Intentintent){Toast.makeText(context,"helloworld",Toast.LENGTH_SHORT).show();}}但是在manifest中可以實(shí)現(xiàn)開機(jī)toast,在代碼中寫的registerReceiver不能實(shí)現(xiàn)開機(jī)toast,這是為什么??
在manifests中注冊開機(jī)啟動可以成功,但是在代碼中注冊開機(jī)啟動不可以,這是為什么?
Qyouu
2019-03-30 11:32:11