0

I have 5 activities in my application A, B, C, D and E. I do login from activity A and go to activity B. Once i am logged in i dont want to go back to A until and unless user logged off. So i have to navigate like B->C->D->E->B.

When i move forward from B->C on button click i use the following:

Intent myIntent = new Intent(v.context, GameClass.class);
startActivity(myIntent);

When i move from C->D->E on button click, i use the following

Intent myIntent = new Intent(v.getContext(), D.class);
startActivity(myIntent);
finish();`
Intent myIntent = new Intent(v.getContext(), E.class);
startActivity(myIntent);
finish();

I am using finish() while moving from C->D->E because when I want to come back from activity E->B I do not want activities C and D in stack. Also when I was not using finish(), after reaching from activity E->B and again move from B->C, activity was directly jumping from B->E so I used finish().

When I do my work and return back from activity E->B, i call only finish(); so that it comes back to activity B. But some times it works and some times it directly reach to activity A. And when it doesn't work it gives this below line:

A/libc: Fatal signal 11 (SIGSEGV) at 0x00000008 (code=1), thread 14392 (Thread-44699)

I have added

android:allowClearUserData="true"
android:hardwareAccelerated="false" 

in AndroidManifest.xml file but still no success.

Can anybody answer why it is working so weird?

Håken Lid
  • 22,318
  • 9
  • 52
  • 67

1 Answers1

0

As you did not provide the full stack trace as @LaurentY suggested, I would like to suggest you a slightly easier way of controlling the flow of your activities.

You could simplify your navigation like this:

  1. In your Android Manifest set Activity Launch Mode of your activities as singleTask: android:launchMode="singleTask". This way you will have only a single instance of your activities running at an any given time.
  2. Don't close your activities with finish(), instead override their onBackPressed() methods and start the appropriate activity in each of those methods. This way you don't have to worry about incorrect activity popping out when user taps back button, as you will have everything under your control.
  3. If you pass some data between activities, you can get them in onNewIntent() method of each activity.

Please, refer to here and here for more information.

ulughbekula
  • 371
  • 1
  • 3
  • 12
  • I have used android:launchMode="singleTask" for activities B->C->D->E and removed the finish() while navigating from C->D->E. I have overridden the method onBackPressed() in activity E so When i am done with my task in activity E i call onBackPressed() explicitly to navigate from E->B but still i am getting the libc error and it is navigating to activity A from E. What could be the problem? – kiran kaple Jun 06 '16 at 06:05
  • Sorry, but without looking at the full activity code, it is being really difficult to guess why you're getting the error. Please, post one of your activity's code (let's say, A and/or B), and the full stack trace, as there might be some really useful info in it. Also, look at [here](http://stackoverflow.com/questions/17840521/android-fatal-signal-11-sigsegv-at-0x636f7d89-code-1-how-can-it-be-tracked), as some people were able to solve the exact problem before. – ulughbekula Jun 06 '16 at 13:35