Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Choose which activity to start on app initializing?

Tags:

java

android

It was hard to summarize the problem in the title but it's really not very complicated.

My problem is this: After installing an app you see an "Open app" button on the play store which initiates your app similarly to when you click run on Eclipse. When you do either of these things the first launcher activity found in the manifest is brought to started.

For example if this were my manifest:

    <!-- Home screen replacemnt -->
    <activity
        android:name=".launcher" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.HOME" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>

    <!-- Launcher Application -->
    <activity
        android:name=".SettingsActivity" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

When open was clicked SettingsActivity would be started since the first activity isn't a launcher app.

My problem is that the first time users open my app I want them to see the launcher. how do I make sure .launcher is started when my application is opened?

like image 940
lisovaccaro Avatar asked Jan 31 '13 07:01

lisovaccaro


People also ask

Where would we specify which activity should launch first in app?

The intent-filter inside the activity tells Android which Activity to launch.

How does Android know which activity to run first?

Unlike programming paradigms in which apps are launched with a main() method, the Android system initiates code in an Activity instance by invoking specific callback methods that correspond to specific stages of its lifecycle.

How do I start an activity from another app?

If both application have the same signature (meaning that both APPS are yours and signed with the same key), you can call your other app activity as follows: Intent LaunchIntent = getActivity(). getPackageManager(). getLaunchIntentForPackage(CALC_PACKAGE_NAME); startActivity(LaunchIntent);

How we can start activity and service in Android?

You can start a service from an activity or other application component by passing an Intent to startService() or startForegroundService() . The Android system calls the service's onStartCommand() method and passes it the Intent , which specifies which service to start.

How do I Use App startup to initialize components automatically?

To use App Startup to initialize components automatically at startup, you must define a component initializer for each component that the app needs to initialize. You define each component initializer by creating a class that implements the Initializer<T> interface.

What is the use of App startup?

App Startup. The App Startup library provides a straightforward, performant way to initialize components at application startup. Both library developers and app developers can use App Startup to streamline startup sequences and explicitly set the order of initialization. Instead of defining separate content providers for each component you need ...

Why app startup initializes workmanager before app startup?

Suppose that your app also depends on a library called ExampleLogger, which in turn depends on WorkManager. This dependency means that you need to make sure that App Startup initializes WorkManager first.

How do I create a second activity for an app?

To create the second activity, follow these steps: In the Project window, right-click the app folder and select New > Activity > Empty Activity. In the Configure Activity window, enter "DisplayMessageActivity" for Activity Name.


1 Answers

You should not distinguish this based on the Intent level. Instead, have a SharedPreferences file for your app, in which you write an integer representing the version if it does not yet exist resp. indicates an older version. Then, based on that mechanism, you implement your "first time install" and/or "first run after update" logic.

like image 186
class stacker Avatar answered Sep 21 '22 06:09

class stacker