public class MyReceiver extends BroadcastReceiver {
private Context mcontext;
TelephonyManager telephonyManager =
(TelephonyManager) mcontext.getSystemService(Context.TELEPHONY_SERVICE);
public void onReceive(Context context, Intent intent) {
mcontext = context;
PhoneStateListener callStateListener = new PhoneStateListener() {
public void onCallStateChanged(int state, String incomingNumber) {
if (state == TelephonyManager.CALL_STATE_RINGING) {
IntentFilter ifilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
Intent batteryStatus = mcontext.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(mcontext,"PLEASE UNPLUG", Toast.LENGTH_LONG).show();
}
}
}
};
telephonyManager.listen(callStateListener, PhoneStateListener.LISTEN_CALL_STATE);
}
}
Asked
Active
Viewed 40 times
0

Antti29
- 2,953
- 12
- 34
- 36

vickychala
- 11
- 4
-
where to want to disable touch? – JAAD Feb 22 '16 at 07:31
-
when the incoming call comes while the phone is charging... – vickychala Feb 22 '16 at 08:36
-
i dont know how to disable complete touch input by setontouchlistener(null) for the above functionality i implemented and revoke the touch interface after when charging is removed... – vickychala Feb 22 '16 at 08:39