New activity seemed to reset default but XML unchanged - android

Can't figure this one out.
I added a second activity to a project in Android Studio. The second activity is now what launches on the emulator instead of the Main Activity.
Below is the XML in the manifest. Do I somehow need to declare the "get_started" activity as a child of the Main?
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".GetStarted"
android:label="#string/title_activity_get_started"
android:theme="#style/AppTheme.NoActionBar"></activity>
</application>

Try adding a DEFAULT intent filter to the MainActivity
<category android:name="android.intent.category.DEFAULT" />

Related

How can i show my splash screen first without making in Mainacitivity

I made a splash screen class name Splash.class . I didnt make in mainacitivity so how i can I show this at first screen (Opening screen or first screen)
Manifest
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/Theme.LoginApp">
<activity
android:name=".second"
android:exported="true"></activity>
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
In order to launch the splash screen first, you have to specify the type of intent by using <intent-filter>. So, adding the below attributes to the activity in your AndroidManifest.xml file will make it launch first:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
In the end, your manifest will look something like this:
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/Theme.LoginApp">
<activity
android:name=".second"
android:exported="true"></activity>
<activity
android:name=".MainActivity"
android:exported="true" />
<activity
android:name=".Splash"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</application>
</manifest>
change your manifest like this
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/Theme.LoginApp">
<activity
android:name=".second"
android:exported="true"></activity>
<activity
android:name="com.your.package.Splash" //put yout class here
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
First time your android will run activity with category LAUNCHER, so change your activity class in category.LAUNCHER with your class (Splash.java)

lunching icon no create

i facing some problem the lunching icon when i running finish the install the file but the lunching icon is not work. i think is i deleted the Main_Activity by default, but i already at the manifest assign the intent default but still cant create the lunching icon.
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".CategoryActivity"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android:intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
You put a : within the <action> tag in the string.
Replace it by a . and it should work :
<action android:name="android.intent.action.MAIN" />

Set an Activity as the initial activity of an android app [duplicate]

This question already has answers here:
Change application's starting activity
(13 answers)
Closed 5 years ago.
In my new android sudio project I created two activities. The first is the MainActivity and the second is called SecondActivity. The second is more like a sort of menĂ¹. Logically, when the app starts, SecondActivity must appear as first.
In the manifest I declared both the activities but I don't know how to declare them correctly so that SecondActivity appears as the first activity in the application after I loaded it on my Android device.
This is my project's manifest :
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".SecondActivity"> </activity>
</application>
Did you tried this, my friend
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity"></activity>
<activity android:name=".SecondActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Two options...
1) Move the intent filter.
2) Switch the android:name property since ordering does not matter
Try this:
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
</activity>
<activity android:name=".SecondActivity"> <intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter></activity>
</application>
The intent-filter tag let you choose trough the action wich activity will be the main.
Simply move the intent filters to the second activity like so:
...
<activity android:name=".SecondActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
...
The parts between the intent-filter tags (<intent-filter> and </intent-filter>) tell Android that this activity should be used when the launcher icon of your app is pressed (i.e. the initial activity).

Android: Changing the default acitivity removes access to application

I'm having an issue changing the default activity in my Android manifest
Initially, the MainAcitivity was the default activity but I would like it to change to the LoginActivity. When I do this however, the app disappears from the app drawer. The only way I can access the app information (uninstall, remove data etc) is via the application manager.
I've changed the tags on the LoginActivity entry in the manifest as suggested here but the issue is still there.
Here is a snippet of my current manifest:
<application
android:name=".ui.MyFirebaseApp"
android:allowBackup="true"
android:fullBackupContent="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/title_activity_login"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="#string/facebook_app_id"/>
<activity
android:name=".ui.MainActivity"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="COMPANY_app_notification_click_action" />
</intent-filter>
</activity>
<activity
android:name=".ui.LoginActivity"
android:label="#string/title_activity_login"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
How would I get the application back to the app drawer?

How to find first activity in Android?

How can I find out from many class file that the particular file is the activity which was created at the time of creating the project?
There is must one Activity as Launcher.
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
It need to define in AndroidManifest.xml so check your AndroidManifest.xml and you could see one launcher activity..
I seen your AndroidManifest.xml which you given link in this case may be DialtactsActivity or DialtactsContactsEntryActivity launcher activity
I don't know if that is what you mean:
In your manifest:
<activity android:name=".mainActivity" android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar"> //THIS IS MAIN BECAUSE THERE IS INTENT_FILTER
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Activity1" android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar" />
<activity android:name=".Activity12" android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar" />
<activity android:name=".Activity123" android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar" />
<activity android:name=".MyProfileActivity" android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar" />

Categories

Resources