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中可以實現(xiàn)開機toast,在代碼中寫的registerReceiver不能實現(xiàn)開機toast,這是為什么??
在manifests中注冊開機啟動可以成功,但是在代碼中注冊開機啟動不可以,這是為什么?
Qyouu
2019-03-30 11:32:11