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. path to sqlite3 database

By default, the sqlite3 database is stored at /data/data/<package
name>/databases/<database name>

Is it possible to change the storage location to a path on the sd card
for example?


If Yes, would this be something like overriding something like the
sqliteopenhelper, setting some global parameter?

Any suggestion/example would be greatly appreciated. Thanks.

-- 

2. <WTS> Xoom, thunderbolt ama pix plus palm

Permisi mau ikutan jualan
1. Palm pixi plus bnib
2. Xoom 3G bnib
3. Thunderbolt bnib ( thunder ready senin/selasa besok)

Harga via japri atau sms ke 085743931455
Terima kasih jalum nya

-- 
"

3. ListActivity Memory leak with onConfigurationChanged

4. parsing an image from an xml file from a network

5. apps-for-android.googlecode.com/svn

6. replace transparent color bitmap with alpha

7. USB cdc_acm was not recognized by host