public class MyReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
try {
IntentFilter ifilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
Intent batteryStatus = context.registerReceiver(null, ifilter);
int status = batteryStatus.getIntExtra(BatteryManager.EXTRA_STATUS, -1);
boolean isCharging = status == BatteryManager.BATTERY_STATUS_CHARGING ||
status == BatteryManager.BATTERY_STATUS_FULL;
if (isCharging == true) {
Toast.makeText(context, "PLEASE UNPLUG", Toast.LENGTH_LONG).show();
}
}
catch(Exception e)
{
System.out.print("e");
}
}
}
我已经实施了检查充电状态的代码..... 我想知道如何在设备充电时禁用broadcastreceiver中的触摸界面?