Android - 在另一个活动中终止进程
我正在让我的主要活动启动另一个将呈现 UI 的活动。当我在第二个活动中尝试从 Eclipse 停止该进程时,该进程立即重新启动!我必须按“后退”一次才能手动停止该进程而不重新启动它
我错过了什么?
主要活动:
package org.test;
import android.app.ActivityGroup;
import android.content.Intent;
import android.os.Bundle;
import android.view.Window;
public class main extends ActivityGroup {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
Intent intent = new Intent(this, ScreenMain.class);
startActivity(intent);
}
@Override
public void onDestroy() {
finish();
}
}
第二项活动:
package org.test;
import android.app.Activity;
import android.os.Bundle;
import android.view.Window;
import android.widget.GridView;
public class ScreenMain extends Activity {
private GridView mGridView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.screen_main);
}
@Override
protected void onDestroy() {
super.onDestroy();
}
}
I'm having my main activity starting another activity which will render the UI. When I try to stop the process from Eclipse while in the second activity, the process just instantly gets restarted! I have to press "Back" once before I can manually stop the process without it being restarted
What am I missing?
Main activity:
package org.test;
import android.app.ActivityGroup;
import android.content.Intent;
import android.os.Bundle;
import android.view.Window;
public class main extends ActivityGroup {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
Intent intent = new Intent(this, ScreenMain.class);
startActivity(intent);
}
@Override
public void onDestroy() {
finish();
}
}
Second activity:
package org.test;
import android.app.Activity;
import android.os.Bundle;
import android.view.Window;
import android.widget.GridView;
public class ScreenMain extends Activity {
private GridView mGridView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.screen_main);
}
@Override
protected void onDestroy() {
super.onDestroy();
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论