开发者

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(savedIn开发者_高级运维stanceState);
    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


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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜