我有3个活动做某种网络访问,并获得与3个相应的XML布局(我将它称为A,B,C)的响应。 A通过Intent将数据传递给B,B通过Intent将数据传递给C.当我执行应用程序时,只有第三个活动/屏幕出现在模拟器上。只有最后一个活动得到显示
我该如何保留序列,比如A先得到显示,然后我点击一个按钮然后去B,然后点击一个按钮,然后转到C.(我是否必须使用活动生命周期,因为每个活动都获得响应。经过网络接入)
代码(相关部分)是:
A-
username = (EditText) findViewById(R.id.editTextusername);
password = (EditText) findViewById(R.id.editTextpassword);
submit = (Button)findViewById(R.id.submit);
//sampletext = (TextView) findViewById(R.id.textView1);
submit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(username.getText().length()>0 && password.getText().length()>0)
{
URLconnector ss = new URLconnector();
ss.execute("SOME URL");
//network access in an async task, get response,
}
Intent part of activity A - on post execute method of async task
if(result != null)
{
Intent intentA = new Intent(mContext, B);
Bundle bundle = new Bundle();
bundle.putString("responsedata",result.substring);
tokenIntent.putExtras(bundle);
startActivity(intentA);
B-
URLconnector ss = new URLconnector();
ss.execute("SOME URL");
//network access in an async task, get response,
}
Intent part of activity B - on post execute method of async task
if(result != null)
{
Intent intentB = new Intent(mContext, c);
startActivity(tokenIntent);
c-
URLconnector ss = new URLconnector();
ss.execute("SOME URL");
//network access in an async task, get response,
}
Intent part of activity c- on post execute method of async task
if(result != null)
{
text3.setText(result);
}
你可以请张贴你的代码吗?一旦你发布它,帮助你将会容易得多。 – MrByte
@DemVoids当然,我已经发布了相关部分。请立即检查。 – androidnoob