running appl in background

by jj » Thu, 09 Apr 2009 15:29:09 GMT

Sponsored Links
 Hello folk
     I want to run application in background. When user close the
foreground screen, application should be running in background. so in
foreground there is no screen of this appl, while user can launch
other appl also.
     To achieve this with the "service component", is it necessary to
create separate process to run this service component or the main appl
process is enough to run service component in background.
        While closing the foreground screen of main appl the process
of this appl is also killed? Or is it remain there to run background

I want suggestion for this issue, Or any other way to attain the goal.

Thank you

running appl in background

by Dianne Hackborn » Thu, 09 Apr 2009 16:26:22 GMT

 Please read the documentation on Service, the overview documentation on
applications (which has a section on process lifecycles/management), and
there are a number of examples in ApiDemos of creating services that run
after an activity finishes.

Dianne Hackborn
Android framework engineer

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.


Sponsored Links

running appl in background

by jj » Mon, 13 Apr 2009 17:35:40 GMT

 If service is running in background in another process,
independent of foreground activity process. As per my study I got the
two  ways to know with background process update,
   1. using IPC(AIDL) bindService()
   2.broadcasting intent from service whenever we want update for
particular function.

     But as far as first option is concerned the foreground activity
should be there running.
My background process should run even though the fore ground activity
is no more on screen. User ca launch other application also while
running my background process.

   So only second option is remains the choice. Or there is any other
   Am I right about bindService() concept[that it remains only the
fore activity is there], is there any other way to keep binding with
backservice, to know update of it even though fore ground is no more
on screen.


running appl in background

by Dianne Hackborn » Tue, 14 Apr 2009 01:13:37 GMT

 No.  You are right that bindService() will keep the target service running
(ONLY  if  you pass in the appropriate flag), but if you use startService()
then the service will remain running even if nothing is bound to it.

Dianne Hackborn
Android framework engineer

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.


Other Threads

1. Click on Notification does not work as expected... (see screencast!):(

Hi guys,

first of all - Merry Christmas!!!

I have a strange problem here and spent too many hours figuring out
what the problem might be. I definitely need your help here now... I'm
pretty sure this is very easy to fix... if you know how...

I develop a little free app for German O2 customers so that they can
send their 50 free Web-SMS directly from their Android phone and not
only via web interface like O2 wants them to. These SMS are sent in
the background using a service. This service generates notifications
(e.g. Message sent successfully, Login successful/failed,...)

When I click on that notification the app should open and then display
the notification message. This works pretty fine as long as the app is
visible (foreground/active). When putting the app into the background
it's getting launched as well, but it doesn't display the message...
then, when I hold down the HOME-Key and select the app... the message
gets displayed.

See the following video... to show you what I mean...

I'm pretty sure it has something to do with the Fflags for my intent,
so here's my code:

Setting the notification:

        // The PendingIntent to launch our activity if the user selects this
        // notification
        final Intent notificationIntent = new Intent(ManagerFactory
                .getMasterActivity(), MailerActivity.class);
                | Intent.FLAG_ACTIVITY_SINGLE_TOP);
        Log.d(TAG, "Set new message to Notification: " + p_message);
                .putExtra(Constants.NOTIFICATION_EXTRA_KEY, p_message);
        Log.d(TAG, "Setting requestCodeToFixNotificationBug: "
                + s_requestCodeToFixNotificationBug);
        final PendingIntent contentIntent = PendingIntent.getActivity(
                ManagerFactory.s_service, s_requestCodeToFixNotificationBug++,
                notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);

                p_message, contentIntent);
Reacting on the incoming intent:

     * (non-Javadoc)
     * @see
    protected final void onNewIntent(final Intent p_intent) {
        // when called via notification, get the extras
        Log.d(TAG, "Called onNewIntent...");
        final Bundle extras = p_intent.getExtras();
        Log.d(TAG, "Extra: " + extras);
        if (extras != null
                && extras.getString(Constants.NOTIFICATION_EXTRA_KEY) != null
                && !extras.getString(Constants.NOTIFICATION_EXTRA_KEY).trim()
                        .equalsIgnoreCase("")) {
            Log.d(TAG, "Extra:"
                    + extras.getString(Constants.NOTIFICATION_EXTRA_KEY));

Would be great if someone was able to help me...



2. How to display XML

Hi all,

Is it possible to display an xml file with all the tags in Webview or the
Browser without first parsing the xml file?
For example, is it possible to display the following
    <body>How are you doing?</body>

without it being parsed to display

Danny Jane Hello How are you doing?

Any help will be appreciated.

3. TableLayout will not draw new row addition

4. File access from computer? (possible?

5. How Does HttpURLConnection work

6. Perkenalan + pertanyaan :)

7. how to add search box on google map??