View Single Post
Old 09-28-2011, 04:03 AM   #10 (permalink)
msdevaf
Knows Where the Search Button Is
 
Join Date: Sep 2011
Model: 9700
PIN: N/A
Carrier: 9700
Posts: 15
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Re: Blackberry System Listener issues

Hi,

To differentiate between usb & adapter charging i make some changes in code. I figure out that when usb is connected then in this method usbConnectionStateChange(int state) state is 18 but when adapter is connected state is 1
so i did this:

public void usbConnectionStateChange(int state) {

if(state!=1){

do what ever you want to do if device is charging by usb

}
}

if adapter is connected to device this method is invoked but since it get state equals to 1 so it does nothing

if usb is connected to device this method is invoked &it get state not equals to 1 so it executes code inside loop

So, half part of my problem is resolved now but since i have to implement functionality if device is charging by adapter so i have implemented that functionality in public void batteryStatusChange(int status)

This method is invoked & it execute code inside loop when device is connected to adapter
But the problem is when device is connected to usb , this method is invoked & it execute code also inside loop. I have use this

public void batteryStatusChange(int status) {
if(status==DeviceInfo.getBatteryStatus()){

do what ever you want to do if device is charging by adapter

}
}

So, how would i compare status so that it execute only when device is connected to adapter?
Offline   Reply With Quote