Unable to call other activity as main activity in Android Studio - android

I wanted to call login_activity (login credentials screen) as main_activity in Android studio.
I have written following code, but when I run the app, it is crashing.
I got to know that we should change the main_acitivity in Android.Manifests.xml file,corrected it, but app still crashing.
<activity
android:name=".LoginActivity"
android:label="My SRIB"
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=".MainActivity"></activity>

Related

Android studio installing APK on phone but can't find the app

I am new to Android Studio and I am trying to deploy an APK to my mobile device in order to test the app. I build the APK successfully but when I install the apk of the app in my device I couldn't see it or cannot be open. But I can see the apps in the app manager showing that I installed it.
here is the code in my manifest file.
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="Pasig NutriCare"
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.DEFAULT" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name=".SplashActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Looking for help.
Thanks in advance.
Did you checked Sort / Alphabetical / Custom ?
Also Check AndroidManifest.xml
Main Activity Should Contains :
Like :
<activity android:name=".SplashActivity"
android:launchMode="singleTask"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden|adjustPan">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
So change .SplashActivity to that you want And Remember to place dot . before it as i did
if you use sub Package Name place it , For Example :
your package is : com.example.myapplication
you create sub package as : activities
so in AndroidManifest.xml you have :
<activity android:name=".activities.SplashActivity"
...
</activity>
Make sure you specify the launcher activity for the app in your AndroidManifest.xml file:
<activity android:name=".YOURACTIVITY" android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Did you specify the launcher activity for the app (in the AndroidManifest.xml)? If all else fails, you can also install the app manually using ADB (android debug bridge)
To install manually, Run this command from terminal/command prompt
adb install path_to_apk

intent filter category android.intent.category.default Default Activity not found

<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#android:style/Theme.Wallpaper.NoTitleBar.Fullscreen">
<activity android:name=".MainActivity"
android:launchMode="singleTask"
android:stateNotNeeded="true">
<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>
<activity android:name=".AppListActivity"/>
</application>
here android.category.default is used to make this application as default launcher like google launcher but when running this application its throwing error default activity not found...i have tried restarting and invalidating cache several times. can anyone help me...?
you can use this,
<activity android:name=".MainActivity"
android:launchMode="singleInstance"
android:stateNotNeeded="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.HOME" />
</intent-filter>
</activity>
Go to Edit Configurations. Within the General tab, in the launch options drop down, select nothing. Now run the app.
You can use Control + Shift + A on Windows or Command + Shift + A on Mac, and type edit configurations to open it.
Just specify activity to lunch in android studio. To do that click on run configuration -> Edit configurations.
In Launch Options pick Specified Activity and then select your activity.

App is restarting while Relaunch from Home app Icon Android Signed Apk:

I create an Android application with three activities.
<application
android:name=".MyApplication"
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:windowSoftInputMode="stateHidden"
android:screenOrientation="landscape" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".LoginActivity"
android:label="#string/app_name"
android:windowSoftInputMode="stateHidden"
android:screenOrientation="landscape" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".EmpSelectionActivity"
android:label="#string/title_activity_emp_selection"
android:windowSoftInputMode="stateHidden"
android:screenOrientation="landscape" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
This is working fine on my Android device (Nexus 5) while I debug the application and run it from Studio directly. But when I generate a signed apk from the studio, the apk is not fetching the preexisting activity while launching from home.
That means: When I Launch the application I select the main Activity from Launcher activity (A login mechanism Over there). Then I press device home icon and click the app icon from device home. Then it's restarting again from the launcher activity instead of the previous MainActivity. But it is not happening while I install the APK without signed one.
Please help me, if anyone have the similar problem and anyone who found the solution.

how to set launch activity for Google Play or APK installer

I have the follow manifest part about application
<application
android:allowBackup="true"
android:icon="#drawable/icon_goodrider_logo"
android:label="#string/app_name"
android:theme="#style/PingTheme" >
<activity
android:name=".passenger.ui.LicenseActivity"
android:label="#string/app_passenger_label"
android:icon="#drawable/icon_logo"
android:taskAffinity="com.city.passenger"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".driver.ui.LicenseActivity"
android:label="#string/app_driver_label"
android:icon="#drawable/icon_logo"
android:taskAffinity="com.city.driver"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
and I want to set launch activity for Google Play Open button (visible after install) or APK install Open button.
Is it possible with out one more launch icon at apps?
Thanks! =)
From my experience, the Open button after the APK was installed is grayed out (disabled) when there are multiple main activities in your AndroidManifest.xml.
Interestingly enough, it seems that this is only the case for pre-ICS devices. In Ice Cream Sandwich, the Open button is clickable and the first Activity in your AndroidManifest.xml with an android.intent.action.MAIN intent filter will be opened on tap.
<activity android:name=".FirstLaunchActivity" android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.INFO" />
</intent-filter>
</activity>

No Launcher Activity found with .Launcher in Manifest.xml already included?

I am trying to run a source code I've found online for android. When I run it, it gives me:
No Launcher activity found!
The launch will only sync the application package on the device!
Performing sync
I already have in my Manifest.xml the following:
action android:name="android.intent.action.MAIN"
category android:name="android.intent.category.LAUNCHER"
What could be wrong? The weird thing is that it worked once. And then when I ran it again it gave me needs to force the application.
It is not a duplicate question because I've read that everyone is suggesting to place those in the Manifest.xml.
I think you need to define a launching activity. For example in my app
<activity android:name=".Main"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
I have defined which activity is started on app start.
please make sur to add android:exported="true" it will be like that
<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>

Categories

Resources