Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7092243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:17:20+00:00 2026-05-28T08:17:20+00:00

I have Android application which is Sales Rep application.When he using the app first

  • 0

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.

I have created like this

     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) ;

    }
}

And My androidManifest File

       <receiver android:name=".service.BatteryLevelActivity">
         <intent-filter>
            <action android:name="android.intent.action.BATTERY_CHANGED" />
        </intent-filter>
    </receiver> 

And Calling place i did like this

     batteryLevelReceiver = new BatteryLevelReceiver();
    IntentFilter intentFilter1 = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
    intentFilter1.addAction(Intent.ACTION_BATTERY_LOW);
    registerReceiver(batteryLevelReceiver, intentFilter1);

It go to BatteryLevelReceiver class. I really don’t know How to check power is plugged or not && how to power off automatically after showing the notification ?

Please anybody help me on this …

Thanks in advance..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T08:17:21+00:00Added an answer on May 28, 2026 at 8:17 am

    To check that the device is plugged in or not you can try this stuff,

    public static boolean isConnected(Context context) {
            Intent intent = context.registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
            int plugged = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1);
            return plugged == BatteryManager.BATTERY_PLUGGED_AC || plugged == BatteryManager.BATTERY_PLUGGED_USB;
        }
    

    For shutting down device here is a thread that you will like to check and for checking the plugged in status already posted the method from this thread.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a android application which needs username and password to login. I need
I have an android application in which I need to get the HTML code
I have web services written using java which interacts with the android application only
I have an Android application which needs username and password to login. I need
I have an Android application which sends some data to a webservice. I need
I have a Android application which provides in-app billing and we have our application
I have an android application which allows the user to take a picture using
I have an Android application which retrieves information from the web using an AsyncTask
I have an Android application with version 1.6 I take the wallpaper and show
I have an Android application which grabs some data from an external XML source.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.