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. Colors from bitmap

hi
        if you are using bitmap, use an integer array to store the bitmap.
use bitmap.getPixel() to get the corresponding bitmap in integer array. By
using bitwise rotation operation, we will get RGB values. (Also byte array
can be used). See the code below.

             int[] pix = new int[picw * pich];
            bitmap.getPixels(pix, 0, picw, 0, 0, picw, pich);

            int R, G, B,Y;

            for (int y = 0; y < pich; y++)
            for (int x = 0; x < picw; x++)
                {
                int index = y * picw + x;
                int R = (pix[index] >> 16) & 0xff;     //bitwise shifting
                int G = (pix[index] >> 8) & 0xff;
                int B = pix[index] & 0xff;

                //R,G.B - Red, Green, Blue
                 //to restore the values after RGB modification, use //next
statement
                pix[index] = 0xff000000 | (R << 16) | (G << 8) | B;
                }

-- 

2. The default Android UI

I was wondering if anyone could tell me about the Android UI,
specifically whether the default UI uses graphics hardware
acceleration or not.

-- 

3. Replace Android Default Home application with my application on runtime.

4. Is that compulsory to use Java developing android apps????

5. Audio hijack?

6. Facing problem while i try to upgrade to the android 2.0

7. proxy setting