Drain the battery... need some advice

I have an application that runs in the background and runs at every 15,30,60 min based on what the user has configured for. I made a quick call to a Web site gets a little info and then farm the connection. I have a realtimeclocklistener to track the number of minutes configuration is passed since the last update.

The problem is the same when it is updated every 60 minutes just, he sits there and drains the battery life. Also the connection arrows top right will go up randomly even after that he made the update. I don't know if it's just consciousness or if that is the question.

Here is the code I am accounting for the data

    public void retrieveData(){
        //Vars
        HttpConnection httpConn = null;
        OutputStream os = null;
        DataInputStream is = null;
        StringBuffer sb = null;
        String separator = "|";
        int chr;
        int index;
        synchronized(this){
            try{
                httpConn = (HttpConnection)Connector.open(myURL, Connector.READ);
                httpConn.setRequestMethod(HttpConnection.GET);
                httpConn.setRequestProperty("Content-Type", "text/plain");
                if(httpConn.getResponseCode() == HttpConnection.HTTP_OK){
                    //Vars
                        os = httpConn.openOutputStream();
                        os.flush();
                        sb = new StringBuffer();
                        is = httpConn.openDataInputStream();
                        while ((chr = is.read()) != -1) { sb.append((char) chr); }
                        String response = new String(sb.toString().getBytes(),"UTF-8");
                        Vector nodes = new Vector();
                        index = response.indexOf(separator);
                    //Code
                    while(index>=0) {
                        nodes.addElement( response.substring(0, index) );
                        response = response.substring(index+separator.length());
                        index = response.indexOf(separator);
                    }
                    nodes.addElement( response );
                    String[] result = new String[ nodes.size() ];
                    if( nodes.size()>0 ) {
                        for(int loop=0; loop

I watched a lot of samples and other code online, and I don't see anything wrong with my code.

Any help will be much appreciated.

That everything seems OK to me.  I would be very surprised if this empty code battery a lot, especially if he did invoke every 60 minutes.  Sure that it does not have anything in your RealtimeClockListener you treat?  Also makes the Thread performing the closing down?  It would seem that you could drive this treatment completely out of the RealtimeClockListener, just start the Thread when you want.  If you did that, then I think that your application would have a minimal impact on the battery.

Tags: BlackBerry Developers

Similar Questions

  • I want to convert my logic large table - multiply in a library called the faster, need some advice on the code of C.

    Hello everyone,

    In my VI, I have a code that looks like this-

    Each table is 2D size 512 by 640.  The time it takes to run this whole chain is approximately 28miliseconds. Seems fast, but I need to cut it to about 10ms.  I tried to make the tables 1 d, but saves only about 2 ms.  I even tried to cut the table 1 d in half and duplicate the code and then combine them at the end (a half-hearted attempt at optimizing multi-core) and who showed zero improvement...

    I guess my last option (please let me know if there are other options) is to compile a DLL that will do this for me.

    I'm a bit confused on how I'm supposed to implement table multiplies in C, however.

    What I do run for(;;) a loop and multiply each item one by one?  It seems that that would be much slower than anything done LabView in-house to do this multiplication of cross-checking.

    Thank you!!

    MK

    If you don't know how you would in C, I don't know why you think that move it to a DLL will make it faster. In C, you will need to either make operations sequentially in a loop for, as you mentioned, or find a library for parallelization of this operation. There is no built-in c function to multiply the tables.

    One thing you might try in your LabVIEW code is to multiply it in a loop for, where you make an addition to each iteration and store the result in a shift register. Also remember the current power of the original array into a shift register. Which should reduce the number of copies of the table you need, which can speed up to turn the code. So, you initialize it the 'sum' with the first table shift register and the shift register current electric table with the result of the subtraction (or, Alternatively, with a table of the same size, filled with 1, according to the order in which you want to do things). Multiply this table by the first multiplier, add it to the sum, and multiply the power of the original (subtraction) table, storing to the power shift register. Repeat until you are finished.

  • (Redirected) Reference DELL 5547 Fan starts while that closed down and drains the battery at 0%, especially may not wake from sleep

    Hello

    When I turn off my laptop the fan starts to spin then and during a night, it drains the battery from 100% to 0. I also have some problems of marketing. If the computer is in sleep mode itself or by me, I can't wake up, need button for 10 seconds and then push again and it starts. When turned on, it works perfectly but has these problems. I read somewhere that the resolution of these problems has been to remove the software intel from my computer and I did. It helped but 2 days computer started having these problems again. My system is Windows 7 64 bit. This problem started after that I have somehow left fully charged computer asleep on the charger for about 2 hours. When I came back fan was spinning and the right side of the laptop was hot. Again, battery life is great and computer has no defects during the work (all tests by dell are passed). What can you suggest me to do?

    As you have a laptop, better make this laptop in the computer Forum post here:

    http://en.community.Dell.com/support-forums/laptop/default.aspx

    Bev.

  • Mail application drains the battery on the iphone 6 (iOS 9.2)

    Hello

    Since the 9.2 update my apple mail app drains the battery really fast. It has 3 accounts (outlook, apple, imap) and tried to extract emails not to push but did not help. When I check in the menu of the battery in the last mail 24 hours with 2 min on screen + 2 min backgroud used 17% (this is equivalent to Facebook 28 min 45 min phone used only 9% or + 22 min back). I tried other email applications, but for me, this one is pretty good and does not want to use another app for something I already have. Is there any solution for this or should I wait for an update of the software?

    Thank you

    Have you tried force reboot the phone by holding down the button sleep and home for 10 seconds, until the Apple logo comes back again?

    You won't lose data, but it can cure some problems after installing new software.

    For some users, deleting the mail account and adding back once the phone reboots worked, especially when you use an exchange account.

  • Fact ' slide to power on "drain the battery? / How to turn it off.

    Just, I got my W520 and noticed that the fingerprint sensor has failed in this setting (after I turn off the led is lit green). How fast did it drain the battery? It is an interesting possibility, but at least I can connect to the password of the bios is nothing more than a gimick I can say.

    -FDP

    No need to go into bios. Open "Thinkvantage fingerprint software"-> settings-> authentication (first tab), under the "safety walk", uncheck the "footprint user digital instead of the power button

  • Smartphones blackBerry CURVE 9220 SLEEVES to the TOP AND DRAINS the BATTERY LIFE

    My blackberry curve 9220 gets really hot and begins to drain the battery.

    the entire battery life is dained out in less than 3 hours

    I try to freshen it, but it does not really.

    and there is no runnig requests in the back except the example by default-, phone, browser, bbm, and messages.

    and the strange thing is that when I turn off the mobile network of the battery keeps draining

    can someone please help I really need my email, bbm and whatsapp return

    Hello and welcome to the community!

    Based on your description, I would deduct low or weak signal from your mobile service provider. Digital devices to modulate their energy consumption depending on the strength of the signal they receive from the Tower of the carrier. Low quality/signal strength, higher battery drain. For good check, you need to contact your mobile service provider, because it is the network, which is the cause. It is possible to have a few problems in the areas that you are in.

    You might also try to start in Safe Mode, to remove all applications 3rd automatic launch party (even if you do not see them in the AppSwitcher Ribbon, they can run):

    • KB17877 How to start a smartphone BlackBerry in Mode safe

    It will take several attempts to get the combination of keys ESC (press/release/hold) OK, so be patient. When properly in Safe Mode, see what happens.

    If the behavior continues, then well... think what happened just before this behavior started? A new application? An update? A theme? Something else? Think carefully that the slightest change can be causal... and try to undo all that was.

    But if the behavior continues mode without failure, you may need to consider more drastic measures - WIPE, OS Reload, BBSAK Wipe/Reload and the process of reloading OS 'skeleton '. To prepare, you should be sure that you have a full backup of your PC... Please see the Backup link in my sig auto on this post for instructions.

    You may also use these tips:

    Good luck and let us know!

  • Smartphones blackBerry 3G signal is originally from draining the battery on my bold 9700

    Hi all

    I don't know if anyone could say this already in the forum. I found nothing when I searched keywords.

    Drain the battery of my bold 9700 seems to be caused by the 3G signal. I know it sounds weird that a signal could cause such a thing.

    With the signal 3G on my battery lasts for 15 minutes at the most. I'm not a hardcore user, I just check my mail and tweet (not all day - some of us have a job to do and may not be on twitter every 2 seconds). The phone would just stop (I don't mean it restarts and I don't get the message informing me in that battery power has been drained).

    I've done the things suggested. I reinstalled the operating system and I went in the distant downgrade the OS OS5, but the question always remained. I've since upgraded to the version of OS6 2949 (latest OS for this phone). I also uninstalled all applications check the cause of the problem.

    My last resort was to disable 3G and don't stay in 2G and in doing so, my phone battery can now last a whole day.

    If I want to use 3G, and not have my phone die on me, I have to put it on a charger. Basically, the phone becomes a landline.

    This could be a possible solution for anyone experiencing the same problem.

    BTW, I've had this phone for almost two years now and I left still completely applications every time I have stop using them, that they are never active in the background.

    My phone details:

    Model: 9700 "Bold"

    Carrier: Vodafone

    OS: version 6 2949 (I think it's the latter)

    Hi Shlain66,

    Thank you for your Post...!

    Please start handheld in safe mode and then watch if battery save increases or not

    Laptop safe mode boot procedure you will find in below URL

    http://BTSC.webapps.BlackBerry.com/BTSC/ViewDocument.do?externalId=KB17877&sliceId=2&cmd=displayKC&d...

  • I use my MacBook Air as a desktop computer. Should I leave the charger plugged all the time or should I drain the battery and then recharge? What is the best for the battery?

    I use my MacBook Air as a desktop computer. Should I leave the charger plugged all the time or should I drain the battery and then recharge? What is the best for the battery?

    Keep the computer plugged in whenever possible.

    If you keep the computer always connected, make sure that at least twice a month

    Run it on battery until battery charge level falls to about 40-50%.

    Please don't completely discharge the battery. Discharge the battery completely will reduce wear and tear on the battery.

    For more information:

    Section: To optimize the battery life

    http://support.Apple.com/en-us/HT204054

    Citing at the bottom of the linked article.

    "The question is often asked:" should I disconnect my laptop from the mains when not in service? Under normal circumstances it should not be necessary because as soon as the lithium-ion battery is full, a properly functioning charger will stop the load and load the pad will only engage when the battery voltage drops to a low level. Most of the users do not remove AC power, and this practice is safe. »

    http://BatteryUniversity.com/learn/article/bu_808c_what_the_user_can_do

  • iPhone drains the battery faster under 9.3.1 - possible?

    Is it just me or drain the battery faster under 9.3.1 on my iPhone 6?

    It feels as if 'normal' use I make of the phone takes less time... In particular, sit and do nothing as during night.  The only thing that I have changed a few months back, it's turning off BT, I lost my helmet, but it was before 9.3.1. Its not horrible, it just feels like it lasts less time...

    Everyone with an iPhone 6 (64 GB in my case) who suffers?

    iDM@iCloud wrote:

    Is it just me or drain the battery faster under 9.3.1 on my iPhone 6?

    It feels as if 'normal' use I make of the phone takes less time... In particular, sit and do nothing as during night.  The only thing that I have changed a few months back, it's turning off BT, I lost my helmet, but it was before 9.3.1. Its not horrible, it just feels like it lasts less time...

    Everyone with an iPhone 6 (64 GB in my case) who suffers?

    http://www.Apple.com/batteries/maximizing-performance/

  • Why will my iPad Pro seems to drain the battery so fast?

    Why will my iPad Pro seems to drain the battery so fast?

    The amount of time that lasts a charge depends on various factors, including what you do with the iPad. Start with the tips in this article. http://www.Apple.com/batteries/maximizing-performance/

    -AJ

  • Is it normal that my iPhone 6 sec to drain the battery overnight so that wifi and cellular data are turned off?

    My 6s iPhone drains the battery overnight

    WiFi and cellular data off

    Not normal.

  • BlackBerry Smartphones BBM drains the battery without the use of telephone (proof)

    (I have a PRIV BB running the latest update of Marshmallow).

    BBM drains the battery.

    I took my PRIV off lunch charger yesterday and weather scheduled 7: 00 the next day morning, that the battery has been completely drained by BBM.

    NOTE IMPORTANT: I did not receive all the BBM messages during this time - sent no BBM messages during this time - didn't even open BBM Meanwhile - didn't even use my phone during this time (I just left it autour sitting in the living room)

    Function checking the battery charge shows that in this period, BBM consumed 40% of my battery (the order of the day closer to you that consumed power was Android OS, but only 8%)

    Here are a few screenshots of the evidence (I've included the statistics pages for following little applications on the list for comparison):

    http://I66.Tinypic.com/2akx9h.jpg

    http://i68.Tinypic.com/29c6vk2.jpg

    http://I66.Tinypic.com/1z5m8g5.jpg

    http://i67.Tinypic.com/4l4xub.jpg

    http://i67.Tinypic.com/2eur1jo.jpg

    I called support for the PRIV BalckBerry and I share my information to troubleshoot with them.

  • I can not install Lightroom 6 on my laptop using 8.1 to WIN.  The installer asks me to connect and when I do after 20 sec freezes the computer and the battery needs to restart.  This prevents the work online help.  What can I do?

    I can not install Lightroom 6 on my laptop using 8.1 to WIN.  The installer asks me to connect and when I do after 20 sec freezes the computer and the battery needs to restart.  This prevents the work online help.  What can I do?

    Settle in the right forum.

  • RV180 need some advice/Suggestion regarding the rules of access and Services

    Hi, I expected to get some advice or suggestion with a RV180 question.  I have a cable modem connection that connects to my port WAN RV180 and we have a single static IP address on the WAN port and everything works great.  We have an internal Exchange Server, so we have a few inbound rules access allowing for ports 443 and 25.  It all works.

    This is the question that I encounter.  We have now another service internal now needs outside inside access on port 443 (https), but I already have this configuration on the router for Exchange and when I have both sense, of course, it won't work correctly because the router just takes the first rules of access and use the one that works very well for traffic Exchange , but not my other service.

    Is there another way to get this job where I can have two internal services on port 443 and the router can forward traffic appropriate to each of them since my first IP? (it doesn't really matter if I had two IP addresses because it always hits the same access list for internal services)

    All advice or suggestion would be great

    Hi, yours is a general networking, not specific to RV180 problem.

    As you have only one IP public (on the WAN port), you only have a single port 443, you can support two services outside-to-inside.

    The cheapest solution is one of the services to another port, if the service permits.

    The most expensive solution is to have public IP addresses.

  • Satellite L750 drains the battery during shutdown

    L750 battery power drains even when the laptop is shut down. I checked power options and seem not to be identical to another laptop that doesn't drain its battery in stop. If I disconnect the battery from the laptop it retains the power OK.

    Any suggestions for what could be the cause?
    Is it sounds like a warranty issue?

    It is certainly not a warranty issue.
    This problem is well known and in the knowledge base of Toshiba, you can find several documents related to this theme.

    Please take some time, visit http://eu.computers.toshiba-europe.com/innovation/generic/TKB_SUPPORT and try to find it.

    If you still need help let us know.

Maybe you are looking for

  • How to connect my Time Capsule to a WiFi network?

    Happily, I use a Time Capsule for years as a WiFi router connected as a bridge to the router provided by my supplier. Now, I'm moving to a place where internet is already provided by an access point in my new apartment and included in the monthly cos

  • Convert time in digital channel display format in a script

    I am trying to convert the display format of a string that contains the time values (mm/dd/yyyy hh:nn:ss.ffff) of time digital. I know I can do this in the Properties section of the data portal, but I want to do in a script. I want to be able to conv

  • interpolate slow 1 d on the basic machine 8

    Hello. I have a very simple question, which is perhaps very simple to solve (for experts). Basically, I got a picture 1024 x 1024 and I have to perform the interpolation along each line. Unfortunately, it is very slow, even though I had a core of 8 P

  • HP F4280 will not scan under OSX 10.6.6

    I just installed a new MAC with os x 10.6.6. and want to continue using my hp Deskjet F4280 3-in-1.  I installed the latest versions of the printer... drivers twice on the hp website and once the full package of APPLE drivers (under the direction of

  • X 220 mSATA recovery disc install hangup...

    Hey all. First off - I am ZIM Black Crow, this is my first time on the boards of Lenovo, because before tonight, I had never owned a Lenovo. But I must say that this community seems incredibly impressive in every way and you guys have been a MAJOR as