0

Will be obliged if someone can help me with this.We were working on some android application,while designing its prototype we came across some issues.A little description of the application's prototype is as follows:

  • A Log in screen
  • a Home screen with logout at its top right
  • Every other activity is having a home button on top right corner. Now going from one activity to the other in my application, I just called finished on the current activity and started the other(so there is no stack of the activities is being created) and when home button present on each activity's top corner is pressed i finish the current activity and move to the home screen.

More precisely,i can say that i am overriding every activty's onBackPressed() method

.By doing this i am not letting android to keep a stack of the activity's but by doing this I have a feeling that, I am loosing efficiency and degrading performance.Because on every backpress or home button click one activity is finished and the other is created.Hence some lag can be seen as the acivity is recreated. Please suggest that should I continue WITH THIS or there is some other way out to handle this Thank you for Giving your time

1 Answer 1

1

It is depends.

If you are giving option on each screen to to go home this approach is good.

Because if you are keep activities in stack it will be in RAM which is limited so it may create memory issue if to many activities in stack.

I would like to suggest one more thing.

As you say you have overridden onBackPressed() method in each activity.

Rather doing this there is a option you can specify parent activity in manifest tag.

So you no need to manually handle by overriding onBackPressed() method.

EG.

<activity
            android:name="com.xxx.DetailActivity"
            android:parentActivityName="com.xxx.src.ListActivity"
            android:screenOrientation="portrait"
            android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
3
  • I would say it is proper way to do that rather onBackPressed() Commented Jul 28, 2014 at 9:48
  • agree with this statement.
    – nobalG
    Commented Jul 28, 2014 at 9:49
  • 1
    That is whole navigation can be handle from one place. Commented Jul 28, 2014 at 9:49

Not the answer you're looking for? Browse other questions tagged or ask your own question.