我在后台进行了4次广播工作并杀死了它,但在oreo版本中却不起作用
我想问问有什么方法可以在后台启动Broad Cast Receiver,杀死
在奥利奥,如果存在的话,那是怎么回事????????? !!!!!
......... 另一个问题是,求职服务可以杀死并取代broadCast ???! ........... ===============================播报================== ===============
@Override
public void onReceive(Context context, Intent intent) {
IntentFilter ifilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
SharedPreferences sp = context.getSharedPreferences("login", 0);
id = sp.getString("id", null);
Intent batteryStatus = context.registerReceiver(null, ifilter);
int status = batteryStatus.getIntExtra(BatteryManager.EXTRA_STATUS, 0);
Log.e("status1111111111", "status: " + status);
boolean isCharging = status == BatteryManager.BATTERY_STATUS_CHARGING || status == BatteryManager.BATTERY_STATUS_FULL; ;
if (isCharging==false){
Toast.makeText(context, "Not Charged", Toast.LENGTH_SHORT).show();
connect="notCharging";
Log.e("isCharging", "isCharging: " + "False");
}
else {
Toast.makeText(context, "Charging", Toast.LENGTH_SHORT).show();
connect="Charging";
Log.e("isCharging", "isCharging: " + "true");
}
==================================清单============= ==================
<receiver
android:name=".Service.ChargeReceiver"
android:enabled="true"
android:exported="false"
android:permission="android.permission.RECEIVE_BOOT_COMPLETED"
android:stopWithTask="false"
>
<intent-filter android:priority="999">
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.BATTERY_CHANGED"></action>
<action android:name="android.intent.action.BATTERY_CHANGED" />
<action android:name="android.intent.action.ACTION_POWER_CONNECTED" />
<action android:name="android.intent.action.ACTION_POWER_DISCONNECTED" />
<action android:name="android.intent.action.BATTERY_LOW" />
<action android:name="android.intent.action.BATTERY_OKAY" />
</intent-filter>
</receiver>