in my application i try to trace an incoming call using AbstractPhoneListener. The call gets traced but the problem is that it generates an error and i have to exit the simulator
I tested on device but when a call arrives nothing happens as i have tried to do!!!!
ERROR = "Access violation reading from 0x00000004"
code:
public class CallTrace extends AbstractPhoneListener
{
CallTrace()
{
}
public void callIncoming(int callId)
{
PhoneCall call = Phone.getCall(callId);
String callNumber = call.getDisplayPhoneNumber();l
System.out.println("call traced!!!!!!!!");
}
}
code:
public class BackgroundListener extends Thread
{
private static PersistentObject timeStore,NPZstore;
private static Vector timeVector,mode;
static CallTrace calltrace;
String[] time1,time2;
int time1Flag=0,time2Flag=0;
public BackgroundListener()
{
calltrace = new CallTrace();
Phone.addPhoneListener(calltrace);
this.start();
}
boolean stopThread = false;
public void run()
{
while (!stopThread)
{
//do some coding here like matching of dates etc.that works well
try
{
sleep(6000) ;
}
catch (Exception e)
{
System.out.println("exception in background thread:"+e);
}
}
}
public synchronized void stop()
{
stopThread = true;
}
protected void onExit()
{
this.stop();
}
}
code:
public class HomeScreen extends UiApplication implements GlobalEventListener
{
private static PersistentObject NPZstore;
private static Vector mode;
static boolean modeValue=false;
static BackgroundListener obj;
public static void main(String[] args)
{
if(args!=null && args[0].equals("gui"))
{
HomeScreen homescreen = new HomeScreen();
homescreen.enterEventDispatcher();
}
else
{
obj = new BackgroundListener();
}
}
HomeScreen()
{
pushScreen(new WorkScreen());
}
public void eventOccurred(long guid, int data0, int data1, Object object0,
Object object1)
{
}
}
class WorkScreen extends MainScreen
{
CustomButtonField REDbutton,GREENbutton;
HorizontalFieldManager hfmRED,hfmGREEN;
private static PersistentObject NPZstore;
private static Vector mode;
boolean modeValue=false;
static CallTrace calltrace;
PopupScreen selectBluetoothType;
final Bitmap background2;
public WorkScreen()
{
//adding some fields here
}
}