我有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