bring running process to foreground or disable multiple instances of application

筅森魡賤 提交于 2019-12-24 14:48:55

问题


im new to android

i have an application that running in the background using moveTaskToBack(true); method

the problem is if user clicked on the application icon it will run another process, not just bring the running one to foreground

how can i solve this???

Example:

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

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);
moveTaskToBack(true);
}, delay);
}

i tried this

<activity android:name=".LaunchActivity" android:label="@string/app_name"
    android:launchMode="singleInstance"
    >
lanchmode=singleinstance

but it didnt work!!

any help?


回答1:


To make the activity not have multiple instances use the activity launchMode parameter in your Manifest. Set it to singleInstance or singleTask.



来源:https://stackoverflow.com/questions/7355783/bring-running-process-to-foreground-or-disable-multiple-instances-of-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!