运行 应用程序后 ,用户按了home按后, 这时应用程序就在后台运行 , 到了某些触发条件时,  应用程序要再次显示出来, 怎样实现 置顶显示出来?

解决方案 »

  1.   

    堆栈中有近期应用程序列表LZ可以将应用程序A 的ManiFest.xml清单文件中相应的Activity加入launcherMode属性   触发条件时  直接调用Intent启动该应用程序launcherMode属性为singleTask模式或者singleInstance模式都是只创建一个实例的。
    当intent到来,需要创建singleTask模式或者singleInstance模式Activity的时候,系统会检查栈里面是否已经有该Activity的实例。如果有直接将intent发送给它。
      

  2.   

    我参考了你的方法 ,试过这样做但不行,  会多了一个新的界面 出来,而且不会在前端显示 出来
    我是这样做的,有不对地方请指出
    1.我在manifest 加入了 android:launchMode="singleTask"     android:alwaysRetainTaskState="true"<manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.abtotest.voiptest"
        android:versionCode="1"
        android:versionName="1.0"   android:launchMode="singleTask"     android:alwaysRetainTaskState="true">
    2. 在程序 要触发事件中加入下面代码 Intent intent = new Intent();
     intent.setClassName("com.abtotest.voiptest", "com.abtotest.voiptest.MainActivity");
     startActivity(intent);
      

  3.   

    android:launchMode="singleTask" 属性你加错地方了...   应该加在你的 MainActivity 中<activity
                android:label="@string/app_name"
                android:name=".MainActivity" 
                android:launchMode="singleTask">
      

  4.   

    这样写的话,不是唤醒后台的Activity,而是重新启动一个Activity。
    应该是把那个Activity类调用onResume()方法
    可以看看http://blog.csdn.net/wangdong20/article/details/8544976
      

  5.   

    我已经这样设置了 <activity
                android:label="@string/app_name"
                android:name=".MainActivity" 
                android:launchMode="singleTask"> ,但程序还是不能在前端显示出来