本文介绍了如何把应用程序的背景吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何把应用程序(活动?)背景,因此它可以在那里工作?

How to put application (activity?) to background so it can work there?

moveTaskToBack(真); 不起作用。我有的android:noHistory =真正的这code:

moveTaskToBack(true); doesn't work. I have android:noHistory="true" and this code:

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) 
{
    switch(keyCode)
    {
        case KeyEvent.KEYCODE_BACK:
            moveTaskToBack(true);
            return true;
    }
    return false;
}

什么是错的?如何把应用程序的背景吗?

What is wrong? How to put application to background?

UPD :也许我可以用moveTaskToBack(真)仅在根(MAIN,LAUNCHER)活性

upd: or maybe I can use moveTaskToBack(true) only in root (MAIN, LAUNCHER) activity?

推荐答案

如果你要跳转到主屏幕,因为一些活动,你可以做到这一点的:

If you want to jump to the home screen because of some activity you can do this:

    Intent i = new Intent(Intent.ACTION_MAIN);
    i.addCategory(Intent.CATEGORY_HOME);
    startActivity(i);

只要确保你正在运行从你的主要活动线程code。在startActivity意味着这个功能是从主要活动运行。

Just make sure you are running the code from your main activity thread. The "startActivity" implies this function is running from the main activity.

这篇关于如何把应用程序的背景吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 06:10