在我的应用程序中,我尝试使用AbstractPhoneListener跟踪来电。 调用被跟踪,但问题是它生成错误,我必须退出模拟器
我在设备上进行了测试但是当一个电话到来时没有任何事情发生,因为我试图做到!!!!
ERROR =“从0x00000004读取访问冲突”
代码:
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!!!!!!!!");
}
}
代码:
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();
}
}
代码:
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
}
}
答案 0 :(得分:0)
这看起来像是由模拟器崩溃导致的Windows错误。所以这不是你的代码中的错误,但可能是模拟器中的错误。我建议downloading and installing a different simulator - 即使它是相同的模型选择最新版本。随JDE一起提供的模拟器通常很陈旧。