Advertisement
Guest User

Untitled

a guest
Apr 24th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.80 KB | None | 0 0
  1. package com.example.hardok.kolosik;
  2.  
  3. import android.content.BroadcastReceiver;
  4. import android.content.Context;
  5. import android.content.Intent;
  6.  
  7. /**
  8.  * Created by hardok .
  9.  */
  10. public class ChargerConnecedListener extends BroadcastReceiver {
  11.     public void onReceive(Context context, Intent intent) {
  12.         String action = intent.getAction();
  13.  
  14.         if (Intent.ACTION_POWER_CONNECTED.equals(action)) {
  15.             Intent i= new Intent(context,MyService.class);
  16.             i.setAction(Intent.ACTION_POWER_CONNECTED);
  17.             context.startService(i);
  18.  
  19.         } else if (Intent.ACTION_POWER_DISCONNECTED.equals(action)) {
  20.             Intent i= new Intent(context,MyService.class);
  21.             i.setAction(Intent.ACTION_POWER_DISCONNECTED);
  22.             context.startService(i);
  23.         }
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement