title: Android Battery Level Notification & after 5 mins shutdown/Power Off the Device
body: <p>I have Android application which is Sales Rep application.When he using the app first need to show the notification like your battery level is 10%  ..., then after 2 minutes if he doesn't plug the power , it automatically need to shut down the device.</p>
  
  <p>I have created like this </p>
  
  <pre><code>     public class BatteryLevelActivity extends BroadcastReceiver{
  
       @Override
       public void onReceive(Context context, Intent intent) {
          int level = intent.getIntExtra("level", 0);  
              Toast.makeText(context, "Battery Level is "+level+"%", Toast.LENGTH_LONG) ;
  
      }
  }
  </code></pre>
  
  <p>And My androidManifest File</p>
  
  <pre><code>       &lt;receiver android:name=".service.BatteryLevelActivity"&gt;
           &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.BATTERY_CHANGED" /&gt;
          &lt;/intent-filter&gt;
      &lt;/receiver&gt; 
  </code></pre>
  
  <p>And Calling place i did like this</p>
  
  <pre><code>     batteryLevelReceiver = new BatteryLevelReceiver();
      IntentFilter intentFilter1 = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
      intentFilter1.addAction(Intent.ACTION_BATTERY_LOW);
      registerReceiver(batteryLevelReceiver, intentFilter1);
  </code></pre>
  
  <p>It go to  <code>BatteryLevelReceiver</code> class. I really don't know How to check <code>power is plugged or not</code> &amp;&amp; how to power off automatically after showing the notification ?</p>
  
  <p>Please anybody help me on this ...</p>
  
  <p>Thanks in advance..</p>