我在android中有一个字符串,在这个字符串中有一个url。所以现在把这个字符串转换成一个put.extra,因为我想把这个字符串赋给一个2.
现在在2.Activity中,我希望接收我的字符串,并使用字符串中的url作为新的/其他字符串。
我该怎么做??
我自己做了一个例子,你可以在下面看到,但是当我运行这个App时,在第二个活动中得到一个空白页面!这段代码有什么问题??
代码示例:
活动字符串定义:
private static final String TAG_PURL = "url";额外的和新的意图:
Bundle bundle = new Bundle ();
bundle.putSerializable(TAG_PURL, purl);
// Starting new intent
Intent postin = new Intent(getApplicationContext(), post.class);
postin.putExtras(bundle);
startActivity(postin);
}
});正在接收额外的:
Intent postin = getIntent();
Bundle bundle = this.getIntent().getExtras();
String purl = (String) bundle.getSerializable (TAG_PURL);在新字符串中使用purl字符串:
private static final String url = TAG_PURL ;发布于 2013-07-12 01:07:46
如果你愿意,你可以试试这个:
private static final String TAG_PURL = "url";
Intent i = new Intent(A.this, B.class);
i.putExtra("URL", TAG_PURL);
startActivity(i);你可以从你的活动b中得到这一点,比如:
Bundle extras = getIntent().getExtras();
String url= extras.getInt("URL");https://stackoverflow.com/questions/17598722
复制相似问题