intent.putExtra("bundle", bundle);
startActivityForResult(intent,0);
}else if(token.equals("user4_login_success")){
bundle.putString(Intent_key, token);
bundle.putString(Intent_url, urlInfo + token);
intent.putExtra("bundle", bundle);
startActivityForResult(intent,0);
}
username=(EditText)findViewById(R.id.username);
password=(EditText)findViewById(R.id.password);
resultTV=(TextView)findViewById(R.id.result);
button=(Button)findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
if("".equals(username.getText().toString())){
Toast.makeText(MainActivity.this, "请登录",
Toast.LENGTH_SHORT).show();
return;
}
new Thread(new Runnable() {
@Override
public void run() {
login();
Messagem=handler.obtainMessage();
handler.sendMessage(m);
}
}).start();
}
});
handler=new Handler(){
@Override
public void handleMessage(Message msg) {
if(result!=null){
resultTV.setText(result);
username.setText("");
password.setText("");
}
super.handleMessage(msg);
}
};
}
//当从secondActivity中返回时调用此函数,清空token
@Override
protected void onActivityResult(int requestCode, int resultCode, Intentdata) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode==0 && resultCode==RESULT_OK){
Bundle bundle = data.getExtras();
String text =null;
if(bundle!=null)
text=bundle.getString("return");
Log.d("text",text);
editor.remove("token");
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/shouji/article-85138-4.html
魂牵梦萦
打