从去年活动的Andr​​oid运行应用程序应用程序、从去年、Andr、oid

2023-09-07 04:56:41 作者:不念则忘。 -

我有几个活动的应用程序。 我的一个活动已在清单意图过滤器参数:action.MAIN 和category.LAUNCHER。加载其存在后,我打电话活动B和 完成()A,因为我不使用它了。

I have an application with several Activities. My A Activity has the Manifest Intent filter parameters: action.MAIN and category.LAUNCHER. after its being loaded I call Activity B and finish() A since I don't use it anymore.

在我跑我的应用程序,从活动一去到B preSS主页 按钮,当我从应用程序菜单或重新启动它 市场应用为前(不通过Home键长preSS),它开始 从A活动,不保存其最后的b活动。

After I run my application, go from Activity A to B and press the Home button, when I relaunch it from the applications menu or from the Market app for ex.(not by a long press on the Home button), it starts from the A Activity and do not save its last Activity B.

我肯定知道这是可能的重新启动应用程序 从上次的活动(从市场的一些应用程序做支撑 它),我认为这可以通过清单参数来确定 但我不知道是哪一个。

I definitely know that this is possible to relaunch an application from its last Activity (some application from the Market do support it) and I think that this can be determined by the Manifest parameters but I don't know which one.

没有人知道如何来实现它,所以我的应用程序可以重新启动 从上次b活动?

does anyone know how to implement it so my application can relaunch from its last Activity B?

谢谢 ayanir

推荐答案

虽然我知道这是一个老问题,我挣扎就此问题,但没有找到一个答案左右。所以,这里是我的(很菜鸟)答案:

Though I know this is an old question, I was struggling with this very issue and couldn't find an answer on SO. So, here is my (very newbie) answer:

没有,我不认为这是可能通过与清单搞乱这样做 - 你只能启动每个应用程序一个固定的活动从主屏幕上。你可以做什么,不过,是什么活动,你想从那个起点的推出,和Android可以做到足够快的速度,你永远不会看到第一个。

No, I do not think it's possible to do this by messing with the manifest - you can only launch one fixed activity per app from the home screen. What you can do, though, is launch whatever activity you want from that starting point, and Android can do it quickly enough that you never see the first one.

虽然这种感觉非常像一个黑客,我实现了这个路由出现在首发活动的的 onResume()方法,并用的共享preferences 来跟踪哪些活动启动:

Though this feels very much like a hack, I implemented this routing in the starting activity's onResume() method, and used sharedPreferences to keep track of which activity to launch:

    final Class<? extends Activity> activityClass;
    SharedPreferences prefs = getSharedPreferences("sharedPrefs", MODE_PRIVATE);
    int activityID = prefs.getInt("whichActivity", -1);
    if (activityID  == Constants.ACTIVITY_ID_MAINSCREEN) {
        activityClass = MainScreen.class;
    } else {
        activityClass = null; return;
    }
    Intent newActivity = new Intent(this, activityClass);
    this.startActivity(newActivity);
 
精彩推荐
图片推荐