Note that there are some explanatory texts on larger screens.

plurals
  1. POpass two strings from one activity to another
    primarykey
    data
    text
    <p>I am working on a tic tac toe application for android. In the Two player section, I've created an activity which will ask the two players to enter their names. For that I've used two <code>EditTexts</code>. The problem is That my app force closes while starting the next activity. Here is my code:</p> <pre><code>//Activity 1: EditText player1field,player2field; Button startbutton; Intent startbuttonintent; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.single_options); setupActionBar(); player1field = (EditText) findViewById(R.id.player1field); player2field = (EditText) findViewById(R.id.player2field); startbuttonintent = new Intent(this, Activity2.class); startbutton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String player1name = player1field.getText().toString(); String player2name = player2field.getText().toString(); startbuttonintent.putExtra("PLAYER1NAME",player1name); startbuttonintent.putExtra("PLAYER2NAME",player2name); startActivity(startbuttonintent); } }); } </code></pre> <p>this is activity 2</p> <pre><code>//Activity2 Intent startbuttonintent = getIntent(); TextView p1name,p2name; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_3m); String player1name = startbuttonintent.getStringExtra("PLAYER1NAME"); String player2name = startbuttonintent.getStringExtra("PLAYER2NAME"); p1name = (TextView) findViewById(R.id.p1name); p2name = (TextView) findViewById(R.id.p2name); p1name.setText(player1name); p2name.setText(player2name); } </code></pre> <p>This code is not giving me any errors but my app force closes when I run it. Please help me. Thanks in advance.</p>
    singulars
    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.
 

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