how to Start onRunning Activity without restarting??

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

how to Start onRunning Activity without restarting??

Postby sit06603 » Sun Jan 04, 2009 4:57 am

hi all,

Happy new year to all...

I have a question on starting the activity...
if the activity is onRunning(already started)
{
How can I call the activity to run, without duplicate and restart the activity???
coz whenever I use this.startActivity(intent); twice, it will start twice
I wan to start onces even I call twices...
if the activity onRunning at background and bring it in front when I second call...
Any idea???
}

else
{
Start as new activity...

}

your attention is much appreciated... thanks...

Wesley.
sit06603
Junior Developer
Junior Developer
 
Posts: 22
Joined: Thu May 15, 2008 11:22 am

Top

Re: how to Start onRunning Activity without restarting??

Postby Sparkletron » Thu Jan 08, 2009 4:48 pm

sit06603 wrote:I wan to start onces even I call twices.


Well I don't know if there's some special Android way of doing this, but in Java you have a number of options. One is to synchronize the method in question. Perhaps...

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.         @Override
  2.         public synchronized void onCreate(Bundle savedInstanceState) {
  3.  
Parsed in 0.030 seconds, using GeSHi 1.0.8.4

This will make all calls to onCreate() queue up so that only one call runs at a time.

Another possibility is to treat the entire object as a singleton.

-S
Sparkletron
Developer
Developer
 
Posts: 26
Joined: Tue Nov 04, 2008 6:17 am

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 5 guests