1
我试图阻止BroadcastReceiver一旦退出我的应用程序就显示出来。到目前为止,我只在安装应用程序时才显示Toast。它工作得很好,除了如果我退出应用程序接收器仍然活跃。 这是从AndroidManifest我的接收器代码:Android Abort BroadcastReceiver
<receiver android:name=".MyBrowdcastreceiver" android:enabled="true">
<intent-filter>
<action android:name="android.intent.action.PACKAGE_ADDED" />
<action android:name="android.intent.action.PACKAGE_INSTALL" />
<data android:scheme="package" />
</intent-filter>
</receiver>
我想知道我应该把我的onDestroy()或者从我的主要活动的onStop()方法,将导致接收机停止。
谢谢。
如果实现了第一,第二只适用... – ThaMe90
我试图以编程方式注册接收这样: BR =新MyBrowdcastreceiver(); IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(Intent.ACTION_PACKAGE_ADDED); intentFilter.addAction(Intent.ACTION_PACKAGE_INSTALL); getApplicationContext()。registerReceiver(br,intentFilter); 但是,现在没有显示烤面包 –
bebug并检查您是否正在使用onReceive()方法获取调用。 –