Home » Android » android – Unable to start activity ComponentInfo…..java.lang.IllegalStateException: Already attached

android – Unable to start activity ComponentInfo…..java.lang.IllegalStateException: Already attached

Posted by: admin June 15, 2020 Leave a comment


I m getting that error ,as you can see i m adding the data that i grabbed from the first activity and storing it into the my array in the second activity .
Then i use the array to populate the list view .So the problem is whenever i click to the save button on the first view

public class Main2Activity extends AppCompatActivity {

protected void onCreate(Bundle savedInstanceState) {
    // setContentView(Your_Layout);
    //Bundle extras = null;
    //if(getIntent().getExtras() != null){
    //    extras = getIntent().getExtras();

    Intent intent = getIntent();
    //  ListView lv = (ListView) findViewById(R.id.View);

    String data = intent.getStringExtra("data");
    String first = intent.getStringExtra("stringOne");
    String second = intent.getStringExtra("stringTwo");
    String Third = intent.getStringExtra("stringThree");
    String Fourth = intent.getStringExtra("stringFour");
    String Fifth = intent.getStringExtra("stringFive");
    String Sixth = intent.getStringExtra("stringSix");

    // Find the ListView resource.
    ListView lv = (ListView) findViewById( R.id.View );

    // Create and populate a List of planet names.
    String[] dataUser = new String[] { first,second,Third,Fourth,Fifth,Sixth};
    ArrayList<String> dataList = new ArrayList<String>();

    // Create ArrayAdapter using the planet list.
    ArrayAdapter<String> listAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, dataList);

    // Set the ArrayAdapter as the ListView's adapter.


How to&Answers:

You have 2 super.onCreate(savedInstanceState); in your code, remove one of them.


So I did remove the extrat super.onCreate(savedInstanceState); that i had but it looks like one of my edit text is passing a nul value .So i went trough every line but as you can see all the edixtext are passing a diffrent of null