Hi,I got answer for my question, We can use moveTaskToBack(true),
This will  Move the task containing this activity to the back of the
activity stack.


On Jun 1, 11:42 am, Archana <[email protected]> wrote:
> Hi,Thanks for the example.So is it possible to exit from my app
> without using finish()
> .Actually in my main activity while calling finish I am unbinding/
> stopping the service and exiting from app.
> But I dont require this in some scenario like when I am launching it
> from third party.like my app must exit,but I want to push my app(not
> service) to run in background.
>
> On Jun 1, 11:05 am, NightGospel <[email protected]> wrote:
>
> > Hi Archana,
>
> > On 6月1日, 下午1時00分, Archana <[email protected]> wrote:
>
> > > Hi  ,thanks for your reply,can you tell me how can i check wedr my app
> > > is running in
> > > background.Now I am checking by long press Home key.Is their any other
> > > way?
>
> > Sure. If you are using Eclair , you can check background running
> > services by Settings application. Settings -> Applications -> Running
> > services, then you will see all running services.
>
> > If you are not using Eclair, you can connect to the device via adb
> > shell command and enter "ps" command to see all processes.
>
> > You can refer tohttp://developer.android.com/guide/developing/tools/adb.html
> > to get more info.
>
> > > If we give this.finish(),our current activity only getting finish,but
> > > stil our app is running in  background.Right?
> > > But I cant see my app in running process.
>
> > If you start one service, it will only be killed when system shutdowns
> > or you call stopService() or call stopSelf() in service itself
> > programmatically.
>
> > For example,
>
> > public class A extends Activity{
> >     public void onCreate(Bundle b){
> >         super.onCreate(b);
> >         setContentView(R.layout.main);
>
> >         Intent i = new Intent(this, B.class);
> >         startService(i);     // we start B here
> >         // stopService(i);   // this is to kill B
> >     }
>
> > }
>
> > public class B extends Service{
> >     private boolean isDestroyed = false;
>
> >     public void onCreate(Bundle b){
> >         super.onCreate(b);
> >     }
>
> >     public void onDestroy(){
> >         super.onDestroy();
> >         isDestroyed = true;
> >     }
>
> >     public void onStart(Intent i, int id){
> >         super.onStart(i, id);
> >         RunningThread thread = new RunningThread();
> >         thread.start();
> >     }
>
> >     public IBinder onBind(){
> >         return null;
> >     }
>
> >     class RunningThread extends Thread{
>
> >         public void run(){
> >             while (!isDestroyed){
>
> >             //  you can put your time-consuming tasks here
> >             .
> >             .
> >             .
> >             // assume we're finished here
> >             stopSelf();   //  this is to kill B
> >             }
> >         }
> >     }
>
> > }
>
> > In above example, if you don't call stopSelf() or stopService(), B
> > will continue running in background.
>
> > NightGospel
>
> > > On May 31, 11:37 am, NightGospel <[email protected]> wrote:
>
> > > > Hi Archana,
>
> > > > This is simple. Just put your time-consuming tasks to a service and it
> > > > will run in background and be destroyed until system shutdown or you
> > > > stop the service programmatically. You can see the link to get more
> > > > info and it can help you to solve this problem.
>
> > > >http://developer.android.com/reference/android/app/Service.html
>
> > > > NightGospel
>
> > > > On 5月31日, 下午2時20分, Archana <[email protected]> wrote:
>
> > > > > Hi,
> > > > > How can we programatically push our app to run in background?
> > > > > I am doing one browser app. and when I am directly launching my
> > > > > application and clicking back key . It will show in the list of
> > > > > background running process.At this time Category is
> > > > > "CATEGORY_LAUNCHER" but at the same time if we try to run same app via
> > > > > third party app.and then clicking back key,its not showing in the list
> > > > > of background running process.Here the Category is
> > > > > "CATEGORY_BROWSABLE".and its not displaying in the list of running
> > > > > process.I noticed that the same behaviour in default android browser.
>
> > > > > But is their any way to make my app to run in background by clicking
> > > > > back key without killing my application?
> > > > > Please help,its very urgent.
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to