Running a program when emulator start

by Jaikishan » Wed, 18 Jun 2008 23:26:39 GMT

Sponsored Links

I was wondering if its possible to start a program automatically in
the background as soon as the emulator gets started? The idea is to
show some message on the status bar.



Running a program when emulator start

by Damien » Wed, 18 Jun 2008 23:51:32 GMT

 Android broadcasts a message on boot. See #BOOT_COMPLETED_ACTION

If you have something listening for this broadcast then it will start
as soon as the
boot has completed.



Sponsored Links

Running a program when emulator start

by Jaikishan Jalan » Thu, 19 Jun 2008 04:01:01 GMT


Thanks for the reply. I understood what you are saying. I wrote my Intent
Receiver which will receive to this broadcast message. Now I want to run a
background process which keeps running forever ( which do some update after
every sometime t). My approach to this problem is this : I am going to write
a Service Calls and call it from the onReceiveIntent method of the
IntentReceiver I wrote. Now, onStart method of the Service Class, I will
create a thread that updates and then sleep for time t and keep running.

Is this a recommended way to approach this problem?


-----Original Message-----
[EMAIL PROTECTED] On Behalf Of Damien
Sent: Wednesday, June 18, 2008 8:51 AM
To: Android Developers
Subject: [android-developers] Re: Running a program when emulator start

Android broadcasts a message on boot. See #BOOT_CO

If you have something listening for this broadcast then it will start
as soon as the
boot has completed.



Running a program when emulator start

by Zach Hobbs » Thu, 19 Jun 2008 10:40:05 GMT

 If you are doing periodic updates I would think about using the AlarmManager 
to kick off the process after specified intervals.  If you create a service 
it's possible that it will be killed by the OS to free resources. 


Zach Hobbs
Android OS news, tutorials, downloads 


Running a program when emulator start

by Jaikishan Jalan » Thu, 19 Jun 2008 14:00:57 GMT

 i Zach,

So, Once I receive the BOOT_COMPLETED_ACTION Intent, what is the problem if
I start a thread which keeps running and sleep for time "t" and then again
start running. Is this a bad approach ? Here is my code :

This code will do some HTTP Post Request every 5 second. The idea is to run
this in the background once my the emulator is started and keep this running
until the mobile is switched off.

import android.content.Context;
import android.content.Intent;
import android.content.IntentReceiver;

public class AddressLogService extends IntentReceiver{
public void onReceiveIntent(Context context, Intent intent) {

Thread tr = new Thread(null,AddressTask,"Address Logger");

private Runnable AddressTask = new Runnable() {

public void run(){

//I do some HTTP Post Request.
}catch(Exception e){}




On Thu, Jun 19, 2008 at 8:09 AM, Zach Hobbs <[EMAIL PROTECTED]> wrote:



Running a program when emulator start

by hackbod » Thu, 19 Jun 2008 16:12:37 GMT

 f you keep yourself running in the background forever, you are taking
those resources from the rest of the system forever. This is not a
polite thing to do. By using the alarm manager, the system has more
freedom to kill your process when it is not needed.

A service that keeps itself running forever but not actually doing
anything most of that time is a big waste of valuable resources, so
something to avoid.

And doing an HTTP operation every 5 seconds is WAY too much. Keep in
mind, every line of code you run is lowering the level of the battery,
every network operation you do is lowering it even more. Doing this
kind of thing every 5 minutes is the minimum scale you should be
thinking about.

On Jun 18, 11:00pm, "Jaikishan Jalan" <[EMAIL PROTECTED]> wrote:

Running a program when emulator start

by Jaikishan Jalan » Thu, 19 Jun 2008 16:22:57 GMT

  completely understand that making an HTTP request every 5 seconds is not
the best way to keep the user happy :). I am just trying to prototype it to
see it working. Ideally, in production the application has to make an http
request once every hour or so. Also, I don't want that even my background
process is sleeping, I don't want to get it killed. It should be killed only
when the user turns off its mobile.

So one application, is when the mobile is started, I will start a background
process. This background process will pull a new quote from a server once
every hour and display it to user. ( Assume for the time being that all the
android mobile user will want this capability [Which I know is not true]).

Do you still I should use AlertManager or run my own thread? One more
related question I had is there any way to measure how much battery power my
background process will overall take ?


On Thu, Jun 19, 2008 at 1:42 PM, hackbod <[EMAIL PROTECTED]> wrote:


Running a program when emulator start

by zero » Thu, 19 Jun 2008 22:12:17 GMT

 ay i suggest another option?
get yoursefl a copy of the latest openintents build,
write a Service class that does whatever you want,
then on some point in your app just call
and you should be good to go :)

On Jun 19, 10:22 am, "Jaikishan Jalan" <[EMAIL PROTECTED]> wrote:

Other Threads

1. Making Video files Android ready for playback over HTTP

I am working on an Android application which is supposed to play
videos over HTTP on Android devices. Before we setup a server to host
the video files just wanted a few things clarified:

As per the developer documentation, Android supports .mp4 and .3gp
container formats for video. The audio-video codec used for our media
files is H.263(video) and AAC LC (Audio).

I did a little experiment and passed URL of one of the video files to
the MediaPlayer class and got the following error:
Command PLAYER_INIT completed with an error or info

video's index (e.g moov atom) should be at the start of the file.

How do we make our videos Android-ready?
What are the different considerations that we need to make?

Please help.



2. OOT: Pak Gunaris Mengudara di Radio JJFM

Nyaris saja kelupaan. 

Pak Gunaris - yang dikenal sebagai suhu GPS akan mengudara
di radio JJFM Surabaya. Tema yang dibahas: "Pelacakan via Seluler"

Kapan? Sore ini pukul 16.00-17.00. 

Rekan yang berada di Surabaya silakan langsung mengubah channel radionya
ke 105,10 FM. 

Sedangkan rekan yang berada di luar Surabaya dapat memantau via radio
streaming. Masuklah ke, kemudian klik online radio.
Maaf, nggak ada direct URL-nya.  

Selama acara berlangsung, pendengar bisa berinteraksi via:
* telepon 031-5483320
* SMS 0815 555 0123

Terima kasih. 


Herry SW

"Indonesian Android Community [id-android]" 

3. 2.2 SDK refresh

4. Bisa diupgrade lagi ngak spicanya

5. question about the Android Git source tree Category

6. Whether to use a Service or Thread for Http Connection?

7. Game Need for speed shift