How does the ActivityStack behave when it contains thousands of Activities?

by Scythe » Sun, 01 May 2011 02:31:44 GMT


Sponsored Links
 In my app I have a about a dozen of different Activities. These
Activities are connected (can call each other with startActivity()) in
such a way, that the user can theoretically keep running in circles -
always jumping to the next Activity, never going back. Also, I really
need to maintain a proper Activity history: if the user presses the
back button, the app returns to the previous Activity, with the
previous content.

Question: Suppose the user's using the app for an extended amount of
time, going in circles between Activites as mentioned above, resulting
an ever-growing ActivityStack. Every Activity saves some state on
onSaveInstanceState() too.

- Is this a problem? (I'm afraid it is, I guess it's a memory leak to
have tens of thousands of Activity records on the stack, especially if
these save their state).
- Is there a way to limit the size of the default Android
ActivityStack's size? (size limit is X, we delete the oldest record if
it gets filled up)

Any suggestions / alternative solutions are welcome.

-- 



Re: How does the ActivityStack behave when it contains thousands of Activities?

by Kumar Bibek » Sun, 01 May 2011 02:36:22 GMT


 You will perhaps run into stack overflows or oom.  Android will try to kill
some of your activities though when it finds necessary



-- 


Sponsored Links


Re: How does the ActivityStack behave when it contains thousands of Activities?

by Dianne Hackborn » Sun, 01 May 2011 04:17:44 GMT


 It doesn't.  Don't do that.  Allowing the user to keep cycling through
activities is fundamentally flawed.  Having an application that has more
than a handful of activities on the stack is not correct, both for the way
the system works and the user experience it causes.







-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

-- 



Other Threads

1. Placing Layouts in a Relative Layout

Hi folks,

i just started developing Android apps and i got a first question
while designing the screen.

What i want to do is do build a login screen.
So i arranged my Labels and Editfields with a TableLayout in Rows.
Below the fields, i want to place a Login Button and a below that, an
image with a logo.

So my idea was to place a TableLayout into a Relative Layout. so i can
arrange my fields using a TableLayout and the Button and Image with
the Relative Layout, but when i want to place my Button below the
table, it appears in the topright corner.

Here is my approach:
<?xml version="1.0" encoding="utf-8"?>


<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/
android"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:padding="10px" >


<TableLayout xmlns:android="http://schemas.android.com/apk/res/
android"
    android:id="@+id/tableLay"
    android:orientation="vertical"
    android:layout_width="fill_parent"
android:layout_height="wrap_content">

    <TableRow android:minHeight="50px">
                <TextView
                android:text="@string/login_user"
        android:paddingRight="20px"
android:layout_gravity="center_vertical"/>
        <EditText android:id="@+id/user"
              android:layout_height="wrap_content"
              android:background="@android:drawable/
editbox_background" android:layout_width="200sp" android:lines="1"
android:maxLength="15" android:inputType="text"
android:layout_gravity="center_vertical" android:focusable="true"/>

    </TableRow>
        <TableRow android:minHeight="50px">
                <TextView
                android:text="@string/login_pass"
                android:paddingRight="20px"
android:layout_gravity="center_vertical"/>
        <EditText android:id="@+id/password"
              android:layout_height="wrap_content"
              android:background="@android:drawable/
editbox_background" android:layout_width="200sp" android:lines="1"
android:maxLength="15" android:inputType="textPassword"
android:layout_gravity="center_vertical"/>

    </TableRow>

    <TableRow android:minHeight="50px">
                <TextView
                android:text="@string/login_licPlate"
                android:paddingRight="20px"
android:layout_gravity="center_vertical"/>

                <EditText android:id="@+id/licPlate"
              android:layout_height="wrap_content"
              android:background="@android:drawable/
editbox_background" android:lines="1" android:maxLength="15"
android:inputType="text" android:layout_gravity="center_vertical"
android:layout_width="wrap_content"/>
        </TableRow>

</TableLayout>

        <Button android:id="@+id/login"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/licPlate"
            android:layout_alignParentRight="true"
            android:layout_marginLeft="10px"
            android:text="Login" />


</RelativeLayout>

Maybe someone can help me with that.

Regards,
Grinarn

--~--~---------~--~----~------------~-------~--~----~

2. Extensible Apps with Scripting or Bytecode Downloading

Hi,
I'm looking into a solution that needs apps to be dynamically
extensible.

One way could be an extension language or scripting engine. I've seen
the Android Scripting Environment, but this needs the actual C
scripting engine (Python or Lua) running as a separate process. I
would like the runtime to be a Java app itself, like JavaScript using
Rhino (and not using a WebView).

Another way is to download Java code dynamically. But, Android does
not support jar downloading and dynamic classloading, since these
bytecode class files are not used directly.

So far there seems to be no solution - your thoughts? Thanks!
--~--~---------~--~----~------------~-------~--~----~

3. VM crash in mobile for a code good working in Emulator

4. Pass data between activitys

5. Work on Android Security as Projec

6. Take an action when soft keyboard is launched

7. samples from media pool never released by OMX MPEG-4 Video Decoder