public void onClick(View v) {
if(v==btLogin)
{
TelephonyManager mngr = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
try{
mobileNo=Long.valueOf(etMobileNo.getText().toString().trim());
password=etPassword.getText().toString().trim();
imeino=Long.valueOf(mngr.getDeviceId());
}catch(NumberFormatException ne){
errormessage=new StringBuilder("Invalid ");
errormessage.append("Failed to parse id " + ne.getMessage());
}
if(etMobileNo.getText().toString().trim().startsWith("0") | etMobileNo.getText().toString().trim().length()<10 | etMobileNo.getText().toString().trim().equals("")| etPassword.getText().toString().trim().equals("")){
Toast.makeText(getBaseContext(),"Mobile No. & Password fields required",Toast.LENGTH_LONG).show();
}else{
System.out.println("Hello");
try{
result=objCommonServices.authenticate(etMobileNo.getText().toString().trim(),etPassword.getText().toString().trim(),mngr.getDeviceId().toString());
System.out.println(result);
if(result.contains("Err-"))
{
System.out.println(result);
Toast.makeText(this,result,Toast.LENGTH_LONG).show();
}else{
showDialog(0);
t = new Thread() {
public void run() {
register();
try {
Thread.sleep(500);
removeDialog(0);
// I want to show the dialog box like registered successfully after removing this dialog//
} catch (InterruptedException e) {
e.printStackTrace();
}
}
};
t.start();
}
}catch(Exception ne){}
}}
void register()
{
try{
String[] split1= result.split(":");
uID= Integer.valueOf(split1[0]);
objCommonBean.setuId(uID);
objCommonBean.setPassword(password);
objCommonBean.setMobileNo(mobileNo);
objCommonBean.setDeviceId(imeino);
Bundle b=new Bundle();
b.putSerializable("objCommonBean",objCommonBean);
this.finish();
startActivity(new Intent(this,HomeActivity.class).putExtras(b));
}catch(Exception e){
} // My Login Page
}
// 我的服务页面包含以下内容
public String authenticate(String mobileNo, String password, String deviceId) {
CommonBean objCommonBean=null;
String result=null;
//StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
//StrictMode.setThreadPolicy(policy);
DefaultHttpClient client=new DefaultHttpClient();
HttpPost request =new HttpPost("http://wsezypoint.ezypoint.org/eauthuzer.aspx");
List<NameValuePair> param=new ArrayList<NameValuePair>();
param.add(new BasicNameValuePair("mobileNo",mobileNo));
param.add(new BasicNameValuePair("password",password));
param.add(new BasicNameValuePair("imei_no",deviceId));
UrlEncodedFormEntity entity=new UrlEncodedFormEntity(param);
request.setEntity(entity);
HttpResponse response = client.execute(request);
InputSource in = new InputSource(response.getEntity().getContent());
InputStream isr=in.getByteStream();
result= readData(isr);
}
我无法从手机登录,但从模拟器我可以登录。是否需要在服务中实施严格的政策或 apk 文件中存在问题,即。生成的文件有误