BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 07-10-2009, 10: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-10-2009, 11:50 PM   #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-10-2009, 11:59 PM   #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

25-PCS DS1845B-050+ POTENTIOMETER WITH MEMORY DUAL NON-VOLATILE 50K 1845B050
$55.42
25-PCS DS1845B-050+ POTENTIOMETER WITH MEMORY DUAL NON-VOLATILE 50K 1845B050 picture25-PCS DS1845B-050 POTENTIOMETER WITH MEMORY DUAL NON-VOLATILE 50K 1845B050
$55.42
25-PCS DS1845B-050 POTENTIOMETER WITH MEMORY DUAL NON-VOLATILE 50K 1845B050 picture20-PCS DS1845B-010+ POTENTIOMETER WITH MEMORY DUAL NON-VOLATILE 10K 1845B010
$48.28
20-PCS DS1845B-010+ POTENTIOMETER WITH MEMORY DUAL NON-VOLATILE 10K 1845B010 picture10-PCS MEMORY IC IDT71V632S7PF SRAM 2MBIT 7NS 100-PIN TQFP IDT 71V632S7
$47.45
10-PCS MEMORY IC IDT71V632S7PF SRAM 2MBIT 7NS 100-PIN TQFP IDT 71V632S7 picture25-PCS DS1845E-010+T&R POTENTIOMETER WITH MEMORY DUAL NON-VOLATILE 10K 1845E010
$50.21
25-PCS DS1845E-010+T&R POTENTIOMETER WITH MEMORY DUAL NON-VOLATILE 10K 1845E010 picture






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