Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
BlackBerry-登录页面上的Dialog.cancel()_Blackberry_Dialog_Listener - Fatal编程技术网

BlackBerry-登录页面上的Dialog.cancel()

BlackBerry-登录页面上的Dialog.cancel(),blackberry,dialog,listener,Blackberry,Dialog,Listener,我有一个接受用户名和密码的登录页面。当用户单击“登录”时,将显示一个加载屏幕“登录…”,后台线程调用一个doLogin()方法,该方法调用一个web服务并加载相应的页面 我面临的问题是在单击登录后从对话框“取消”登录。取消()。它取消加载屏幕,但后台线程仍在处理,即使单击“取消”,也会加载新页面。如何取消后台线程 threadbackgroundworker=新线程(new Runnable()){ 公开募捐{ 多洛金(联埃特派团,pwd); } }); Dialog busyDialog=新建

我有一个接受用户名和密码的登录页面。当用户单击“登录”时,将显示一个加载屏幕“登录…”,后台线程调用一个doLogin()方法,该方法调用一个web服务并加载相应的页面

我面临的问题是在单击登录后从
对话框“取消”登录。取消()
。它取消加载屏幕,但后台线程仍在处理,即使单击“取消”,也会加载新页面。如何取消后台线程

threadbackgroundworker=新线程(new Runnable()){
公开募捐{
多洛金(联埃特派团,pwd);
}
});
Dialog busyDialog=新建对话框(“登录…”,
新字符串[]{“取消”},
新建int[]{Dialog.CANCEL},
Dialog.CANCEL,
位图.getPredefinedBitmap(位图.HOURGLASS))
{
公共无效字段已更改(字段field1,int context1)
{
//停止登录并关闭加载屏幕的内容
}
};
busyDialog.setEscapeEnabled(false);
busyDialog.show();
backgroundWorker.start();
它调用的推送新屏幕的方法是
doLogin()

private String doLogin(字符串用户id、字符串密码)
{
SoapObject resultRequestSOAP=null;
HttpConnection httpConn=null;
http传输httpt;
SoapPrimitive响应=null;
SoapObject请求=新的SoapObject(名称空间、方法名称);
request.addProperty(“用户名”,用户id);
request.addProperty(“密码”,password);
System.out.println(“请求为===”+请求.toString());
SoapSerializationEnvelope=新的SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet=true;
envelope.setOutputSoapObject(请求);
httpt=新的HttpTransport(URL+C0connection\U扩展);
httpt.debug=true;
尝试
{
调用(SOAP_操作、信封);
response=(SoapPrimitive)envelope.getResponse();
字符串结果=response.toString();
resultRequestSOAP=(SoapObject)envelope.bodyIn;
字符串[]listResult=split(结果,sep);
strResult=listResult[0].toString();
如果(标准结果等于(“认证”))
{
警告(“无效的登录详细信息”);
}
其他的
{
strsessionFirstName=listResult[1].toString();
strsessionLastName=listResult[2].toString();
strsessionPictureUrl=MAINURL+listResult[3]。子字符串(2);
strsessionStatusId=listResult[4].toString();
strsessionStatusMessage=listResult[5].toString();
strSessionLastUpdateSt=listResult[6].toString();
}
如果(标准结果等于(“已接受证书”))
{
if(checkBox1.getChecked()==true)
{
persistenthastable.put(“用户名”,用户id);
persistentHashtable.put(“密码”,password);
}
位图位图=getLiveImage(strsessionPictureUrl,140,140);
nextScreen.getUsername(用户id);
nextScreen.getPassword(密码);
nextScreen.setPictureUrl(位图);
nextScreen.setImage(strsessionPictureUrl);
setFirstName(strsessionFirstName、strsessionLastName、strSessionLastUpdateST、strsessionStatusMessage);
UiApplication.getUiApplication().invokeLater(新的Runnable())
{
公开作废运行()
{
UiApplication.getUiApplication().pushScreen(下一屏幕);
}
} );
}
}捕获(IOE异常){
System.out.println(“异常为IO==”+e.getMessage());
}catch(XMLPullParseRexE){
System.out.println(“异常xml解析器示例==”
+e.getMessage());
}
System.out.println(resultRequestSOAP);
返回响应+“”;
} 

您可能需要在类中添加一个
boolean
成员变量,在
doLogin()方法中进行多步检查:

private boolean stopRequested=false;
私有同步的void requestStop(){
stopRequested=true;
}
私有同步布尔值isStopRequested(){
要求退货;
}
私有字符串doLogin(字符串用户id、字符串密码)
{          
SoapObject resultRequestSOAP=null;
HttpConnection httpConn=null;
http传输httpt;
SoapPrimitive响应=null;
SoapObject请求=新的SoapObject(名称空间、方法名称);
request.addProperty(“用户名”,用户id);
request.addProperty(“密码”,password);
System.out.println(“请求为===”+请求.toString());
SoapSerializationEnvelope=新的SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet=true;
envelope.setOutputSoapObject(请求);
httpt=新的HttpTransport(URL+C0connection\U扩展);
httpt.debug=true;
if(isStopRequested())返回null;
尝试
{          
调用(SOAP_操作、信封);
response=(SoapPrimitive)envelope.getResponse();
字符串结果=response.toString();
resultRequestSOAP=(SoapObject)envelope.bodyIn;
字符串[]listResult=split(结果,sep);
strResult=listResult[0].toString();
如果(标准结果等于(“认证”))
{          
警告(“无效的登录详细信息”);
}          
其他的
{          
strsessionFirstName=listResult[1].toString();
strsessionLast