Help in the first Android activity

When my application first opens my first action, which is presented to the user, it may change depending on the configuration settings. I only know how to hard-code the first action that is executed when the application starts, 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> 

Where MyFirstActivity is the name of the class of the first activity class to be launched. How can I dynamically choose which activity to start first when the application starts first, rather than hard-coded it in the manifest?

Thanks!

+4
source share
1 answer

Option # 1: In onCreate() of MyFirstActivity call startActivity() for the correct action, then finish() .

Option # 2: Define several actions using the LAUNCHER <intent-filter> , but all are disabled. At the first start (or if necessary), enable the correct action and disable the others. Disadvantage: the phone may need to be rebooted to update the launcher, as not all on-screen launchers will detect your changes.

Option # 3: Change your GUI so that it is not a problem.

+9
source

Source: https://habr.com/ru/post/1334869/


All Articles