BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 07-10-2009, 11:34 PM   #1 (permalink)
Knows Where the Search Button Is
 
Join Date: May 2008
Model: 9700
OS: 5.0.0.330
PIN: 217FEEC9
Carrier: T-Mobile
Posts: 31
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Quick Newbie Question

Please Login to Remove!

This program is basically the HelloWorld application and I'm trying to retrieve the battery level by way of getBatteryLevel() to bnum. I'm pretty unaware of why I get the "Cannot find symbol area" seeing as I imported the needed classes supposedly and it only returns a int, but here it goes:

Code:
/*
 * InfoProgram.java
 *
 *  <your company here>, 2003-2005
 * Confidential and proprietary.
 */

package src;

import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.system.RadioInfo.*;
import net.rim.device.api.system.DeviceInfo;



/**
 * 
 */
class InfoProgram extends UiApplication
 {
    public static void main(String[] args)
    {
        InfoProgram App = new InfoProgram();
        App.enterEventDispatcher();
    }
    
    public InfoProgram()
    {
        pushScreen(new InfoProgramScreen());
    }
}

final class InfoProgramScreen extends MainScreen
{
        public InfoProgramScreen()
    {
        super();
        LabelField title = new LabelField("InfoProgram", LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH);
        setTitle(title);

        int bnum = getBatteryLevel();
        add(new RichTextField("Battery Level: "+bnum));
    }
    
    public boolean onClose()
    {
        Dialog.alert("Goodbye!");
        System.exit(0);
        return true;
    }
}
Offline  
Old 07-11-2009, 12:50 AM   #2 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default

getBatteryLevel() is a method of DeviceInfo, not MainScreen.

The code should be:

int bnum = DeviceInfo.getBatteryLevel()
Offline  
Old 07-11-2009, 12:59 AM   #3 (permalink)
Knows Where the Search Button Is
 
Join Date: May 2008
Model: 9700
OS: 5.0.0.330
PIN: 217FEEC9
Carrier: T-Mobile
Posts: 31
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by Dougsg38p View Post
getBatteryLevel() is a method of DeviceInfo, not MainScreen.

The code should be:

int bnum = DeviceInfo.getBatteryLevel()
Thanks, was sorta wracking my brain over trying to fix it..
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.