0

i have 3 Activity in my application and i'm reaching a activity either with a bundle and without bundle and i'm trying to check the bundle null or not. If it's null, open activity, if it's not null write the value to edittext.

here is my code.

Bundle veriAl = getIntent().getExtras();

EditText who_detail = (EditText)findViewById(R.id.who_detail);
String gelen_deger = veriAl.getString("reply_user").toString();

if(gelen_deger.equals(""))
{
   who_detail.setText(veriAl.getString("reply_user"));
}
4

2 に答える 2

3

try this :

if(veriAl != null){
String gelen_deger = veriAl.getString("reply_user").toString();
}else{
//you got null from bundle
//open other activity here 
}
于 2012-10-31T09:57:00.200 に答える
1

Use:

String gelen_deger="";
if(veriAl != null && veriAl.containsKey("reply_user")) gelen_deger = veriAl.getString("reply_user").toString();
于 2012-10-31T09:59:23.727 に答える