[英]bring running process to foreground or disable multiple instances of application
im new to android 我是Android新手
i have an application that running in the background using moveTaskToBack(true); 我有一个使用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? 有什么帮助吗?
To make the activity not have multiple instances use the activity launchMode parameter in your Manifest. 要使活动没有多个实例,请在清单中使用活动launchMode参数 。 Set it to
singleInstance
or singleTask
. 将其设置为
singleInstance
或singleTask
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.