user935143
user935143

Reputation: 564

android app run at start up and in background

im new to android, i made an application and i want it to run at start up automatically and in the background for sure, can anybody help me with this???? regards

for example:

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    int delay = 10000;// in ms 

    Timer timer = new Timer();

    timer.schedule( new TimerTask(){
       public void run() { 
           AudioManager audio=((AudioManager) getSystemService(AUDIO_SERVICE));
            audio.setRingerMode(AudioManager.RINGER_MODE_VIBRATE);
        }
     }, delay);

}

i want this code to run at startup and in background

Upvotes: 0

Views: 868

Answers (2)

Android Killer
Android Killer

Reputation: 18489

If you want anything run in background then you should take the help of services not activity.

Upvotes: 0

Dan S
Dan S

Reputation: 9189

Listen for this broadcast Intent with a BroadcastReceiver and tell the system about it with a Android Manifest receiver.

Upvotes: 1

Related Questions