问题
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