English 中文(简体)
开始在 Android 导航堆的顶端活动
原标题:Start activity at top of navigation stack in Android

我正在执行 Tabactivity 的解决办法,其活动在 TabHost < a href="http://ericharlow.blogspot.com/2010/09/experience-multiple-android-activities.html>>>http://echarlow.blogspot.com/2010/09/rel=“nofollow.blogspot.com/2010/09/ex-multive-multiple-and mild-activities.html/a>中。 我意识到这是次最佳的,但我已经走这条路已经很远了,只有剩下的一个哈卡。 我需要跳到我管理的堆顶部(使用活动标识 列表 )。

Activity current = getLocalActivityManager().getActivity(mIdList.get(0));

然而,我不知道一种“展示” current 的方法。

我知道我能做到这一点:

Activity current = getLocalActivityManager().getActivity(mIdList.get(1))
current.finish();

如果堆叠上至少有两个活动, 这将产生预期的结果。 但是, 当堆叠上只有一个活动时, 它会以 < code> ArrayOutobsBoundsExpendation 出现非常糟糕的失败 。

我怎么能"展示"一个特定的活动?

最佳回答

尝试以此方式启动一个活动堆叠中始终位于顶端的活动 :

List<ActivityManager.RunningTaskInfo> processes1 = activityManager.getRunningTasks(1);
ComponentName componentInfo = processes1.get(0).topActivity;
String classname =processes1.get(0).topActivity.getClassName(); 
String packagename = processes1.get(0).topActivity.getPackageName();
if(classname.equalsIgnoreCase("com.YOUR_PACKAGE_NAME..YOURACTIVITY_NAME"))
    {
        Intent intent24 = new Intent(Intent.ACTION_MAIN).addCategory(
        Intent.CATEGORY_LAUNCHER).setClassName("YOUR_PACKAGE_NAME",
        "com.YOUR_PACKAGE_NAME..YOURACTIVITY_NAME").addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
        .addFlags(Intent.FLAG_FROM_BACKGROUND).setComponent(new ComponentName("YOUR_PACKAGE_NAME",
        "com.YOUR_PACKAGE_NAME..YOURACTIVITY_NAME"));
        getApplicationContext().startActivity(intent24);
    }
    else
    {
     //DONE SOMETHING HERE...
    }
问题回答

暂无回答




相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签