将正在运行的进程到前台或禁用应用程序的多个实例 [英] bring running process to foreground or disable multiple instances of application

查看:152
本文介绍了将正在运行的进程到前台或禁用应用程序的多个实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

即时通讯新到Android

im new to android

我有在后台运行的应用程序
使用moveTaskToBack(真);方法

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???

例如:

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);
}

我想这

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

但它没有工作!

任何帮助吗?

推荐答案

为使活动不能有多个实例使用活动的 launchMode参数的清单。将其设置为 singleInstance singleTask

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

这篇关于将正在运行的进程到前台或禁用应用程序的多个实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆