Android: DEFAULT activity showing up instead of LAUNCHER - java

I am making a simple Android Application, which consists of only two activities, .Password and .Adder
<activity
android:name=".Adder"
android:label="#string/title_activity_adder" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".Password"
android:label="#string/title_activity_adder" >
<intent-filter>
<action android:name="android.intent.action.PASSWORD" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
The .Password activity is set as the LAUNCHER but when I run it, the .Adder Activity shows us instead.
I have the .xml and .java file for both the activity properly connected by setContentView() and Eclipse is not reporting any kind of error in any file at all.
The Password Activity checks for the correct password and switches control to the Adder Activity:
Intent openStartingPoint = new Intent("com.example.pointsadder.MAIN");
startActivity(openStartingPoint);

You don t have to write intent filter to each activity. Correct xml:
<activity
android:name=".Adder"
android:label="#string/title_activity_adder" >
</activity>
<activity
android:name=".Password"
android:label="#string/title_activity_adder" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

Change this:
<activity
android:name=".Password"
android:label="#string/title_activity_adder" >
<intent-filter>
<action android:name="android.intent.action.PASSWORD" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
to this:
<activity
android:name=".Password"
android:label="#string/title_activity_adder" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
And modify this as shown:
<activity
android:name=".Adder"
android:label="#string/title_activity_adder" >
</activity>
Refer to this link: http://developer.android.com/guide/topics/manifest/manifest-intro.html#iconlabel for more details.

Related

Android Studio generates three separate apps after I compiled and ran in the android emulator

I have upgraded my Android studio.
I think there is something different from the previous version
When I finished writing the code and compile then run. I look something different like this:
Whether it's something new or I destructive my android studio settings
May be you create multiple intent-filter in android AndroidManifest.xml.
this is happening because you have posted below code in three different activities in AndroidManifest.xml file.
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
the mistake you have done is like below in AndroidManifest.xml file:
<activity
android:name=".SplashActivity"
android:launchMode="singleTop"
android:screenOrientation="sensorPortrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".HomeActivity"
android:launchMode="singleTop"
android:screenOrientation="sensorPortrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:screenOrientation="sensorPortrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

How to remove splash activity from an existing project?

I have an existing Android Studio project and i wanted to remove splash screen. I tried to remove changes in AndroidManifest.xml but couldn't make it.
Here this my actual AndroidManifest.xml
<!-- Home Tab Group -->
<activity
android:name=".view.TabHomeActivity"
android:label="#string/app_name"
android:windowSoftInputMode="adjustPan|stateHidden" >
</activity>
<activity
android:name=".view.activity.SplashActivity"
android:label="#string/app_name"
android:windowSoftInputMode="adjustPan|stateHidden" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".view.activity.TestLoginFacebookActivity"
android:configChanges="keyboardHidden|orientation"
>
</activity>
<!-- Tab Screen -->
<activity android:name=".view.tabscreen.TabHomeScreen"
android:windowSoftInputMode="stateAlwaysHidden|adjustResize" />
Delete the SplashActivity class,delete it from the manifest. Set the Launching Activity first which you want to come as your first screen
<activity
android:name=".view.TabHomeActivity"
android:label="#string/app_name"
android:windowSoftInputMode="adjustPan|stateHidden" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".view.activity.TestLoginFacebookActivity"
android:configChanges="keyboardHidden|orientation"
>
</activity>
Delete the SplashActivity class,
delete it's layout,
delete it from the manifest.
Add the intent filters to your TabHomeActivity.
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

How to change launcher activity

I imported one eclipse project into android studio, which have one main activity "MainActivity". Now I created a second activity "Main2Activity". I want to assign this (Main2Activity) as launcher activity. When user install the app the second app should open first.
I also tried to change the AndroidManifest file as given below, but no luck...
<activity
android:name="com.myapp.mytime.Main2Activity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.myapp.mytime.MainActivity"></activity>
Could any one help?
Please check your Main2Activity.Java file i think there is setContentView(R.layout.activity_main); instead of this setContentView(R.layout.activity_main2);
As I've seen you have this code on your Main2Activity
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
You just have to clean your project and press run. You should be good to go.
Try this
<activity
android:name="com.myapp.mytime.Main2Activity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.myapp.mytime.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
Also Check if you load MainActivity programmatically or not and Also Clean the project. and remove the application from device before running on it after doing these changes.

How to run last viewed activity after resume?

I've got an android application. If I go through activities(for example MainTabActivity->SearchMapActivity->ListBranchesActivity) and then hide(not close) my application, android will run the main (MainTabActivity) activity after reopen. If I press "back" button, android will show me the last activity (ListBranchesActivity). How can I make my app show the last activity after resuming? I really have no idea how to achieve that. Somebody says to add singleTask statement to manifest.
My manifest:
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#android:style/Theme.Holo"
android:largeHeap="true" >
<activity
android:name=".SearchMapActivity"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:configChanges="keyboardHidden|orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".UpdateActivity"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:configChanges="keyboardHidden|orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".CompanyInfoActivity"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:configChanges="keyboardHidden|orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".FullMapActivity"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:configChanges="keyboardHidden|orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".ListBranchesActivity"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:configChanges="keyboardHidden|orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".ListCompaniesByBranchActivity"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:configChanges="keyboardHidden|orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".SearchResultActivity"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:configChanges="keyboardHidden|orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".MainTabActivity"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:configChanges="keyboardHidden|orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Also that thing doesn't happen everytime. Sometimes it shows last activity, sometimes - main activity.
> Also that thing doesn't happen everytime. Sometimes
> it shows last activity, sometimes - main activity.
Sometime android closes your app if it needs memory. So even if you hide(not close) ...[the] application, it might have been closed anyway

No Launcher activity found

I can't find any problem but it keep giving me the error "No Launcher activity found!" and "The launch will only sync the application package on the device!"
can anyone solve this problem???
This is my Maniest
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.saikoro.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.example.saikoro.StartUp"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.example.saikoro.StartUp" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
The <activity> element of the activity you want to launch through the icon on the app list must contain both of the following parts of the intent-filter:
<intent-filter>
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.MAIN" />
</intent-filter>
Your current manifest has an activity with category LAUNCHER and action MAIN, but in different activities. The one with the icon in the app list must have them both.
Change
<action android:name="com.example.saikoro.StartUp" />
with
<action android:name="android.intent.action.MAIN" />

Categories

Resources