开发者

Intent on Android

I want a clarification on intent.this is my scenario,there are 3 activities in my project namely "A","B","C"..... On clicking the button in Activity "A" ,i pass the values to "B" through bundle and based on the received value i retrieved set of values from database...Similarly "B"->"C" also...

开发者_运维技巧

The problem when i clicked the back button in "C" it does not proceed to "B" rather throws a error.similarly "B" to "A" also....

i found the reason that "B" can not get value from bundle when clicking Back button from "C"

Hope you understand.what's the solution....

Thanks in advance


Try starting our Activity using startActivityForResult and use setResult(int) to send the result back from Activity C to B


that true you saying bundle getting null values, so you have to prevent that null values, like first check bundle values if not Equals null then only set

Intent myintent = getIntent();
if (null != myintent.getExtras()) {
    // do your work here
    String Name = myintent.getExtras().getString("Name");
} else {
    // not here you can't get values
    // so getting force close here
    Toast.makeText(getApplicationContext(), "No Recor Here..", 12).show();
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜