English 中文(简体)
组织安乐斯的活动。 国家。 方便?
原标题:Organizing Activity in Android. States. Easy?

请看图表:https://i.stack.imgur.com/G2lfN.png

我对我的 app结构有一些麻烦。 我有几次活动/情况,如果你接触到,就不允许你回去。 页: 1

很方便的是START。 活动。 一旦我做了一些工作来决定我是否去了KA,我就跑了START.finish(有KA)。 活动与紧靠背后台的临近时间为START。 活动不再存在。

问题始于X状态。 申请像你一样需要完全完成3个步骤,以便:

[START-> [A<->B<->C->[X>/strong>]->]

所需经费在紧靠背顿时:

www.un.org/Depts/DGACM/index_spanish.htm 接近

on B: show A

www.un.org/Depts/DGACM/index_french.htm

如果你最终完成某种izar干(A->B->C),你就可到X

请求:我应如何完成(a) A, B, C, 防止背后纽顿出X? 我没有提及使用。

最佳回答

One way to achieve this, is in activity X, make pressing the back button fire of a custom event.

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK) {
        backPressed();
        return true;
    }
    return super.onKeyDown(keyCode, event);
}

public void backPressed()
{
   Globals.finished = true;
   finish();
}

You ll notice the above method has the line Globals.finished = true; This refers to a class called Global with a static (static can be called on a class without having to instantiate an object) boolean variable called finished that is initially set to false as follows. In my own apps I often use a Globals class for sharing things common to the whole app. You can also used the shared preferences to do somthing similar.

public class Globals
{
  public static finished = false;
}

Then in the onResume (or possibly onStart) lifecycle method of all activities you can put the following

if (Globals.finished == true)
    finish();

这将导致所有活动立即结束,但只有在全球各地的完全变数出现之后。 我以前就这样做了,而且工作得很好,并将确保这些活动把生命周期方法称作结束。

Even simpler than this, you could avoid the use of the back button event handler, by setting the Globals.finished = true, in the onClose method of ActivityX.

问题回答

您需要打上<代码>finish()>,在你想要完成的活动中,一切照旧。 利用Actative forResult,帮助你恢复完成学业

You can refer this LINK.

您可在A、B、C等活动的档案中添加和roid:无History=“true”,即......

sample code for manifeast look like

<activity android:label="string resource" android:name="activityA" android:noHistory="true" />




相关问题
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 ...