Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to pass a String between two activities in Android?
    primarykey
    data
    text
    <p>Here I have created 2 Activities in my project.</p> <pre><code>public class CheckAvailability extends Activity{ Button but1,but2; EditText brName; TextView txt1; String text; //private static final String ATM_NO = "atmbrno"; //private static final String ATM_PLACE = "atmbrname"; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.availability); brName =(EditText)findViewById(R.id.editText1); but1 = (Button)findViewById(R.id.button5); but2 = (Button)findViewById(R.id.button6); but1.setOnClickListener(new View.OnClickListener(){ public void onClick(View v){ String b_name=brName.getText().toString(); Intent intent1 = new Intent(); intent1.setClass(getApplicationContext(), ListAtmActivity.class); Bundle b = new Bundle(); b.putString("key", b_name); intent1.putExtras(b); startActivity(intent1); finish();} }); but2.setOnClickListener(new View.OnClickListener(){ public void onClick(View v){ Intent intent1 = new Intent(); intent1.setClass(getApplicationContext(), SelectOption.class); startActivity(intent1); } }); } } </code></pre> <p>And I want to pass b_name String value to the other Activity. and here is my 2nd Activity.</p> <pre><code>public class ListAtmActivity extends ListActivity{ TextView error; String brName; // contacts JSONArray JSONArray contacts = null; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.list_main); Bundle b = getIntent().getExtras(); brName = b.getString("key"); error = (TextView)findViewById(R.id.name); error.setText(brName);}} </code></pre> <p>But I cant get that string in my 2nd activity? Please help me to find the error?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload