Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.hardok.kolosik;
- import android.content.BroadcastReceiver;
- import android.content.Context;
- import android.content.Intent;
- /**
- * Created by hardok .
- */
- public class ChargerConnecedListener extends BroadcastReceiver {
- public void onReceive(Context context, Intent intent) {
- String action = intent.getAction();
- if (Intent.ACTION_POWER_CONNECTED.equals(action)) {
- Intent i= new Intent(context,MyService.class);
- i.setAction(Intent.ACTION_POWER_CONNECTED);
- context.startService(i);
- } else if (Intent.ACTION_POWER_DISCONNECTED.equals(action)) {
- Intent i= new Intent(context,MyService.class);
- i.setAction(Intent.ACTION_POWER_DISCONNECTED);
- context.startService(i);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement