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 8994537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:27:17+00:00 2026-06-15T23:27:17+00:00

I am using : UIDevice *myDevice = [UIDevice currentDevice]; [myDevice setBatteryMonitoringEnabled:YES]; float batLeft =

  • 0

I am using :

UIDevice *myDevice = [UIDevice currentDevice];
[myDevice setBatteryMonitoringEnabled:YES];
float batLeft = [myDevice batteryLevel];
int i = [myDevice batteryState];    
int batinfo = batLeft * 100;

to find the battery status.
I am looking out to find, how to find the time remaining until the charge is complete.
ex: 1 hour 20 min remaining.
How can I find it programmatically?

  • 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-06-15T23:27:18+00:00Added an answer on June 15, 2026 at 11:27 pm

    I haven’t found any method for this in the official documentation, neither in the class-dumped, private header of the UIDevice class.

    So we have to come up with something. The best “solution” I have in mind at the moment is similar to the approach taken when estimating download time: calculating an average speed of download/charging, and dividing the remaining amount (of data or charge) by that speed:

    [UIDevice currentDevice].batteryMonitoringEnabled = YES;
    float prevBatteryLev = [UIDevice currentDevice].batteryLevel;
    NSDate *startDate = [NSDate date];
    
    [[NSNotificationCenter defaultCenter]
        addObserver:self
           selector:@selector(batteryCharged)
               name:UIDeviceBatteryLevelDidChangeNotification
             object:nil
    ];
    
    - (void)batteryCharged
    {
        float currBatteryLev = [UIDevice currentDevice].batteryLevel;
        // calculate speed of chargement
        float avgChgSpeed = (prevBatteryLev - currBatteryLev) / [startDate timeIntervalSinceNow];
        // get how much the battery needs to be charged yet
        float remBatteryLev = 1.0 - currBatteryLev;
        // divide the two to obtain the remaining charge time
        NSTimeInterval remSeconds = remBatteryLev / avgChgSpeed;
        // convert/format `remSeconds' as appropriate
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using this function to get current battery level of device: [[UIDevice currentDevice] setBatteryMonitoringEnabled:YES];
We've noticed that UTF8 characters don't come out correctly when using UIDevice.CurrentDevice.Name in MonoTouch.
I am using this to set device orientation, [[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeRight]; but it is
([UIDevice currentDevice].orientation); using the above code in my app, all i get is 0
I have a simple question. How do I get iPhone's battery level? [UIDevice currentDevice]
I want to query the orientation the iPhone is currently in. Using [UIDevice currentDevice].orientation
Hey this is the code I am using switch ([[UIDevice currentDevice] orientation]) { case
I am using the following code to set the device orientation [[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeRight];
I am using [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(detectOrientation) name:@UIDeviceOrientationDidChangeNotification object:nil]; to make
I have using the following code for get identifier deviceName = [[UIDevice currentDevice]uniqueIdentifier]; But

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.