0
假設我有一項活動獲取一個cookie,然後開始一項新活動。如何將cookie傳遞給新的活動?
Intent myIntent = new Intent(this, act2.class);
this.startActivity(myIntent);
但是,如何將該cookie傳遞給新的活動?
謝謝!
假設我有一項活動獲取一個cookie,然後開始一項新活動。如何將cookie傳遞給新的活動?
Intent myIntent = new Intent(this, act2.class);
this.startActivity(myIntent);
但是,如何將該cookie傳遞給新的活動?
謝謝!
您可以使用Intent.putExtra傳遞間的數據:
Intent myIntent = new Intent(this, act2.class);
myIntent.putExtra("CookieKey",cookieValue);
this.startActivity(myIntent);
,並在其他活動中,你可以使用
String cookie=getIntent().getStringExtra("CookieKey");
或以更清晰的方式,你可以用得到這個演員兩項活動。
謝謝,使cookieValue,我只是不MyCookie.toString()? – 2012-03-01 13:23:04
此外,我以後如何再次將該字符串轉換回cookie? :) – 2012-03-01 13:24:50