Android的:如何使发射器始终打开的主要活动,而不是子活动? (或其他) [英] Android: How to make launcher always open the main activity instead of child activity? (or otherwise)

查看:133
本文介绍了Android的:如何使发射器始终打开的主要活动,而不是子活动? (或其他)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有活动,A和B,A是一个与发射台的意图过滤器(即启动时我们点击主屏幕上的应用程序图标的活动)。

I have activities A and B. The A is the one with LAUNCHER intent-filter (i.e. the activity that is started when we click the app icon on home screen).

一个推出乙 startActivity(新意图(A.this,B.class))

当用户有B活性开,然后把我的应用程序进入后台,后来我的应用程序的过程中被杀害,当用户再次启动我的应用程序,B被打开,而不是一个。

When the user has the B activity open, and then put my application into the background, and later my application's process is killed, when the user starts my application again, B is opened instead of A.

这引起了强制关闭我的应用程序,因为A是初始化资源,我的应用程序需求的活动,而当B试图访问未初始化的资源,B崩溃。

This caused a force close in my app, because A is the activity that initializes the resources my app needs, and when B tried to access the uninitialized resources, B crashes.

你有什么建议,我该怎么办在这种情况下?

Do you have any suggestions what should I do in this situation?

推荐答案

那么你真的应该有b活动初始化资源了。但你可以把<一href="http://developer.android.com/guide/topics/manifest/activity-element.html#clear"><$c$c>android:clearTaskOnLaunch="true"在您的舱单活性的有发射经常去该活动。

Well you should really have activity B initialize your resources too. But you can put android:clearTaskOnLaunch="true" in your manifest for activity A to have the launcher always go to that activity.

这篇关于Android的:如何使发射器始终打开的主要活动,而不是子活动? (或其他)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆