帮助首款Android活动 [英] Help with first Android Activity
问题描述
在我的应用程序第一次打开即psented用户$ P $可以根据配置选项因我的第一项活动。我只知道如何到c,当应用程序被添加像这样的清单运行运行的第一个活动硬$ C $
When my app first opens my first activity that is presented to the user can vary based on configuration options. I only know how to hard code the first activity that runs when the app is running by adding something like this in the Manifest
<activity android:label="@string/app_name" android:name=".MyFirstActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
在哪里MyFirstActivity是第一个活动类的要运行的类名。如何动态选择哪些活动首先运行时,应用程序首次启动而不是C很难$ C $在清单?
Where MyFirstActivity is the class name of the first activity class to be run. How can I dynamically select which activity to run first when the app is first launched rather than hard code it in the manifest?
谢谢!
推荐答案
选项#1:在的onCreate()
的 MyFirstActivity
,呼叫 startActivity()
为正确的活动,那么完成()
。
Option #1: In onCreate()
of MyFirstActivity
, call startActivity()
for the right activity, then finish()
.
选项2:定义了若干活动与 LAUNCHER
&LT;意向滤光器&gt;
,所有,但一个残疾人。在第一次运行(或需要),使正确的活动,并禁止其他人。下行:可能需要重新启动手机来更新发射器,因为不是所有的主屏幕发射器会检测你的变化
Option #2: Define several activities with the LAUNCHER
<intent-filter>
, all but one disabled. On first run (or as needed), enable the right activity and disable the others. Downside: may require a phone reboot to update the launcher, since not all home screen launchers will detect your change.
选项#3:重新设计您的GUI,使得这不是一个问题
Option #3: Redesign your GUI such that this is not an issue.
这篇关于帮助首款Android活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!