Activitiy Behavior

by Shekhar » Fri, 23 Apr 2010 01:21:02 GMT


Sponsored Links
 I have a problem.

I have to design an application in which three activities A ,B,C are
such that if I move across the activities, previous
activities are not killed.A,B,C should be in the application stack so
that their OnCreate
function is not called everytime.Activities should be killed only when
finish() is called explicitly.What is the solution for it?

Also what intent flag I should use to call another activity?

Thanks,
Shekhar

--



Activitiy Behavior

by Mark Murphy » Fri, 23 Apr 2010 01:31:11 GMT


 


If the user goes from A -> B -> C, then presses the BACK button, C will
be destroyed. If the user presses the BACK button again, B will be
destroyed.

If the user goes from A -> B, then takes a phone call and meanders away
from your application for a while, A or B may be destroyed to free up
RAM (though you will be able to use onSaveInstanceState() to retain some
knowledge of your current condition).

None of that is avoidable. All of that is very important for the proper
operation of the users' phones.

The only way to have the functionality of A, B, and C all exist as a
unit is for it all to *be* a unit -- having a *single* activity do all
three things.

On the whole, I think Android works better where A, B, and C can work
independently, and so I really recommend you consider why your design
requires those activities to all be in memory at the same time.


I do not understand this question, sorry.

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com  |  http://twitter.com/commonsguy 

Android Training in US: 14-18 June 2010:  http://bignerdranch.com 

--


Sponsored Links


Activitiy Behavior

by Shekhar » Fri, 23 Apr 2010 01:55:48 GMT


 Hi,

1.Thanks for your prompt reply.Why I need to have all the three
activities in the stack because I  want to avoid the time it takes
to create the activity.So that user will not feel smoother screen
transition.to explain in a better way suppose that A and B activity
has a text view that updates the timer that is updated from a common
place.

Only objective is to have a smoother transition.

2.What is the use of "Single Top" activity.If I press back key on a
single top activity.Will it be killed?

Thanks,
Shekhar





>



Activitiy Behavior

by Mark Murphy » Fri, 23 Apr 2010 02:02:06 GMT


 


Then improve the performance of the activities, so they start up faster.

Or, redesign the UI such that the transition time between activities is
not going to be distracting for users.


Yes.

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com  |  http://twitter.com/commonsguy 

Android Online Training: 10-14 May 2010:  http://onlc.com 

--



Activitiy Behavior

by Shekhar » Fri, 23 Apr 2010 02:22:05 GMT


 Hi Murphy,

Thanks for your suggestions.

I have a basic querry.suppose all  the three activities are declared
as singletop and suppose from activity A i call
B activity with intent flag as

i.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
startActvity(i)

and from B->C the same intent.Now if i call the activity Aor B from C
with the same intent flag .will the oncreate() function of A,B will be
called again?

If not then it means that the A,B,C are there in the application stack
and their old instance is called again? Am I right?

Thanks,
Shekhar





>



Activitiy Behavior

by Shekhar » Fri, 23 Apr 2010 02:24:09 GMT


 Hi Murphy,

Thanks for your suggestions.

I have a basic querry.suppose all  the three activities are declared
as singletop and suppose from activity A i call
B activity with intent flag as

i.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
startActvity(i)

and from B->C the same intent.Now if i call the activity Aor B from C
with the same intent flag .will the oncreate() function of A,B will be
called again?

If not then it means that the A,B,C are there in the application stack
and their old instance is called again? Am I right?

Thanks,
Shekhar





>



Activitiy Behavior

by Mark Murphy » Fri, 23 Apr 2010 02:29:53 GMT


 


Possibly. Those activities might have been destroyed (e.g., to free up RAM).


AFAIK, yes.

However, bear in mind that the user can press the BACK button, which
will destroy an activity, regardless of singleTop or whatever.

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com  |  http://twitter.com/commonsguy 

Android Online Training: 10-14 May 2010:  http://onlc.com 

--



Activitiy Behavior

by faizan khan » Fri, 23 Apr 2010 02:39:21 GMT


 use ViewFlipper whereby you can flip views in the same activity and get the
desired result.






>



Other Threads

1. Android OpenGL Game - App Architecture and Threading Logic

Surprisingly, I don't seem to have issues with the OpenGL side of
things (which is very unusual), but my problems stem from getting a
clear idea for app architecture and a few other problems.
Right now, most tutorials on the net just describe the render portion.
I know that when I create a GLSurfaceView and hook a Renderer into it,
it uses it's own thread for rendering.

I want to do logic operations and other gameplay stuff (like moving
characters and whatnot) in it's own thread as well. Can anyone explain
a good approach to this? I'm guessing the two threads will have to be
synchronized (do logic, render, repeat), and limited based on time so
that it performs smoothly across different devices.

-- 

2. 'Squeezing' a button on the right side

Hi,

you probably heard similar problems before but i can't figure out how
to do this programatically. I have a vertical layout with FILL_PARENT
on both dimensions. In it i have multiple horizontal layouts with
FILL_PARENT width and WRAP_CONTENT height. In each of these horizontal
layouts i want to put a checkbox on the left and an ImageButton on the
right. The problem is i can't stop the checkbox from growing to the
point of pushing the ImageButton out of view.. (same thing happens
when the checkbox has FILL_PARENT or WRAP_CONTENT widths).

For individual stuff i managed to do it in the XML layout very easily:

<...something... android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:layout_weight="1" />

<...something... android:layout_width="wrap_content"
                        android:layout_height="wrap_content" />

Same thing doesn't work programatically though, and i've tried other
gravity, weight, layout combinations.. Can someone who tried this tell
me how they did it, or how it should be done?

Thanks,
Teo

-- 

3. Dvalve! we called the heart of outsourcing world. Dvalve.com

4. Unable to get a reference to included layout...

5. Help please...

6. Is SignalStrength readable outside onSignalStrengthschanged?

7. Ada anak jogja gak neh ?