更改AndroidManifest.xml以根据共享首选项设置启动器活动
我有一个注册活动,也是一个主要活动 我想要实现的目标: 我想: 1) 如果用户尚未注册,则显示注册活动 2) 如果用户已注册,则显示主要活动 我所做的: 1) 我已将注册活动更改为Android.Manifest.xml文件中的主/启动器活动:更改AndroidManifest.xml以根据共享首选项设置启动器活动,android,android-manifest,Android,Android Manifest,我有一个注册活动,也是一个主要活动 我想要实现的目标: 我想: 1) 如果用户尚未注册,则显示注册活动 2) 如果用户已注册,则显示主要活动 我所做的: 1) 我已将注册活动更改为Android.Manifest.xml文件中的主/启动器活动: <activity android:name=".MainActivity" android:label="@string/app_name" > </activity> &
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
</activity>
<activity
android:name=".RegistrationActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
如果您不希望应用程序登录到当前主应用程序,则需要为应用程序创建登录页并在其中运行该方法。因此,
run
方法是转到main的方法
我更喜欢将我的共享首选项作为应用程序的常量
pref = getSharedPreferences(MyConstants.MY_APP);
editor = pref.edit();
public void run(View view) {
String getStatus = pref.getString(MyConstants.REGISTER, "nil");
if (getStatus.equals("true")) {
startActivity(new Intent(this, Main.class));
} else {
Toast.makeText(this, "Register first",
Toast.LENGTH_SHORT).show();
}
}
在注册课程中:
editor.putString(MyConstants.REGISTER, "true");
editor.commit();
使用splash或launcher screenHi@r7v,是否可以使用splash screen?我的注册活动也有一些活动,输入用户名和密码活动,输入其他详细信息活动(这是BTNRegisteressed所在的位置)谢谢@Heyyou,请帮助。您不能动态更改启动器屏幕。将活动(Splash/Launcher)作为启动器活动,并在活动的onCreate()上执行逻辑。
editor.putString(MyConstants.REGISTER, "true");
editor.commit();