小编Jor*_*gón的帖子

通过单击应用程序图标打开Android应用程序

我是Android开发世界的新手,我已经构建了一个简单的"Hello World"应用程序.首先,活动请求文本.单击"开始"按钮后,应用程序将启动显示输入文本的第二个活动.

如果我单击HOME按钮然后单击应用程序图标,应用程序将再次启动第一个活动,但如果我按住主页按钮并单击"最近的应用程序"栏中的图标,它将恢复我离开的应用程序.

我该如何避免这种情况?

即使单击了启动器图标,我也需要恢复应用程序.

MainActivity.java,

package com.example.myfirstandroidapp;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.EditText;

public class MainActivity extends Activity {
  public final static String EXTRA_MESSAGE = "com.example.myfirstapp.MESSAGE";
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
  }

  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
  }
  /** Called when the user clicks the Send button */
  public void …
Run Code Online (Sandbox Code Playgroud)

android restart android-launcher android-homebutton

11
推荐指数
1
解决办法
1万
查看次数