本文整理汇总了Java中android.app.ActivityManager.moveTaskToFront方法的典型用法代码示例。如果您正苦于以下问题:Java ActivityManager.moveTaskToFront方法的具体用法?Java ActivityManager.moveTaskToFront怎么用?Java ActivityManager.moveTaskToFront使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.app.ActivityManager
的用法示例。
在下文中一共展示了ActivityManager.moveTaskToFront方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isAppOnForeground
import android.app.ActivityManager; //导入方法依赖的package包/类
@SuppressLint({"NewApi"})
public static boolean isAppOnForeground(Context mContext) {
ActivityManager activityManager = (ActivityManager) mContext.getSystemService("activity");
String packageName = mContext.getPackageName();
LogInfo.log("PushReceiver", "packageName =" + packageName);
List<RunningAppProcessInfo> appProcesses = activityManager.getRunningAppProcesses();
if (appProcesses == null) {
LogInfo.log("PushReceiver", "------appProcesses == null-----");
return false;
}
for (RunningAppProcessInfo appProcess : appProcesses) {
LogInfo.log("PushReceiver", "------appProcess.processName =" + appProcess.processName);
if (appProcess.processName.equals(packageName) && appProcess.importance == 100) {
for (RunningTaskInfo rti : activityManager.getRunningTasks(100)) {
if (!(rti == null || rti.baseActivity == null || mContext.getPackageName() == null || !mContext.getPackageName().equals(rti.baseActivity.getPackageName()) || VERSION.SDK_INT < 11)) {
activityManager.moveTaskToFront(rti.id, 1);
}
}
return true;
}
}
return false;
}
示例2: bring2Front
import android.app.ActivityManager; //导入方法依赖的package包/类
/**
* 将当前应用运行到前台
*/
private void bring2Front()
{
ActivityManager activtyManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
List<ActivityManager.RunningTaskInfo> runningTaskInfos = activtyManager.getRunningTasks(3);
for (ActivityManager.RunningTaskInfo runningTaskInfo : runningTaskInfos)
{
if (this.getPackageName().equals(runningTaskInfo.topActivity.getPackageName()))
{
activtyManager.moveTaskToFront(runningTaskInfo.id, ActivityManager.MOVE_TASK_WITH_HOME);
return;
}
}
}
示例3: onPause
import android.app.ActivityManager; //导入方法依赖的package包/类
@Override
protected void onPause() {
LocalBroadcastManager.getInstance(this).unregisterReceiver(mRegistrationBroadcastReceiver);
isReceiverRegistered = false;
ActivityManager activityManager = (ActivityManager) getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE);
activityManager.moveTaskToFront(getTaskId(), 0);
super.onPause();
}
示例4: pushLiveOver
import android.app.ActivityManager; //导入方法依赖的package包/类
@SuppressLint({"NewApi"})
private void pushLiveOver() {
LetvConstant.setForcePlay(false);
StatisticsUtils.setActionProperty(NetworkUtils.DELIMITER_LINE, -1, NetworkUtils.DELIMITER_LINE);
if (MainActivity.getInstance() != null) {
if (this.isShowToast) {
UIsUtils.showToast(TipUtils.getTipMessage("70004", 2131100703));
}
ActivityManager am = (ActivityManager) this.mContext.getSystemService("activity");
for (RunningTaskInfo rti : am.getRunningTasks(100)) {
if (!(rti == null || rti.baseActivity == null || this.mContext.getPackageName() == null || !this.mContext.getPackageName().equals(rti.baseActivity.getPackageName()))) {
if (VERSION.SDK_INT >= 11) {
am.moveTaskToFront(rti.id, 1);
}
LogInfo.log("push_", "moveTaskToFront rti.id = " + rti.id);
}
}
if (TextUtils.isEmpty(this.cid)) {
MainLaunchUtils.launch(MainActivity.getInstance(), true);
} else if (!(this.cid.equals("3") || this.cid.equals("8") || this.cid.equals("4") || this.cid.equals("9"))) {
MainLaunchUtils.launch(MainActivity.getInstance(), true);
}
LogInfo.log("push_", "pushLiveOver live pushCid " + this.cid);
return;
}
if (TextUtils.isEmpty(this.cid)) {
MainLaunchUtils.launch(this.mContext, true);
} else if (this.cid.equals("3")) {
MainLaunchUtils.launchGotoLive(this.mContext, "ent", null, this.isShowToast, true);
} else if (this.cid.equals("8")) {
MainLaunchUtils.launchGotoLive(this.mContext, "other", null, this.isShowToast, true);
} else if (this.cid.equals("4")) {
MainLaunchUtils.launchGotoLive(this.mContext, "sports", null, this.isShowToast, true);
} else if (this.cid.equals("9")) {
MainLaunchUtils.launchGotoLive(this.mContext, "music", null, this.isShowToast, true);
} else {
MainLaunchUtils.launch(this.mContext, true);
}
LogInfo.log("push_", "pushLiveOver MainActivity.getInstance() == null no jump to live");
}
示例5: bring2Front
import android.app.ActivityManager; //导入方法依赖的package包/类
/**
* 将当前应用运行到前台
*/
private void bring2Front(Context context) {
ActivityManager activtyManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
List<ActivityManager.RunningTaskInfo> runningTaskInfos = activtyManager.getRunningTasks(3);
for (ActivityManager.RunningTaskInfo runningTaskInfo : runningTaskInfos) {
if (context.getPackageName().equals(runningTaskInfo.topActivity.getPackageName())) {
activtyManager.moveTaskToFront(runningTaskInfo.id, ActivityManager.MOVE_TASK_WITH_HOME);
return;
}
}
}