Reputation: 619
I am making an app which is intendended to help the user practice vocabulary. It has 6 activities, which are called «Activity1», «Activity2» etc.
Activity3 starts gathering information, and puts it in a String array. This is being passed to the next activities using Bundle. After an evaluation in Activity6, one of the buttons offers the user to go back to Activity4 again, to repeat the exercise. I try to make this happen by creating a new intent which points to Activity3, but on the emulator-screen I get the following message: «Unfortunately the app has stopped». I really cannot figure out why. Can I point more than one Intent to the same activity, or is there any problem with doing that? (Both Activity2, and now Activity6 points to Activity3).
Unfortunately I am not yet as familiar with using Log.Cat as I should. I will work on that, meanwhile I send some code. Posting all code is probably to much, but here is the code I think is relevant:
In Activity2 I use the following code to create an Intent, and to pass information to Activity3:
btnEnd.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
vocabularyArray[arraySize]editForeignWord.getText().toString();
vocabularyArray[100 + arraySize] =
editTranslation.getText().toString();
Bundle b = new Bundle();
b.putStringArray("vocabularyArrayToPass", vocabularyArray);
b.putInt("array_size", arraySize);
Intent intentGoTo3 = new Intent(Activity2.this,
Activity3.class);
intentGoTo3.putExtras(b);
startActivity(intentGoTo3);
}
});
and in Activity6 I use the following code to get back to Activity3:
btnAgain.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intentGoTo3 = new Intent(Activity6.this,Activity3.class);
startActivity(intentGoTo3);
}
});
Upvotes: 0
Views: 92
Reputation: 251
I don't think there's any problem with your code,it is perfect. You should try to check the log cat for the error. You Can get there by following this step: Android Studio :: On Downside in android studio you can See "Android Monitor" Tab. So When you click at that menu you can see the log cat menu and after that you can scroll up or scroll down for the error. The errors will be shown in RED Color.
Upvotes: 1