android how to change the starting activity - java

I have built an application with one activity for android. I now want to add a LOGIN page which should be run first. how can I change the application to run login first?
my first activity was MainActivity.java. I went to the application's properties -> run/debug settings -> edit conf. -> Launch action. But there is only Mainactivity, I cannot see Login activity.
I am using Eclipse, by the way.
Is there an easy way to fix this?

Modify the manifest:
<activity
android:name=".YOUR_LOGIN_ACTIVITY"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
and modify entry of MainActivity as
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
</activity>
Update
You should read Declaring the activity in the manifest and use of intent filters for more. [Search for 'Using intent filters']

Inside your AndroidManifest change following line: android:name="com.example.webviewdemo.MainActivity" put your login Activity with including package name like com.example.login.LoginActivity.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.webviewdemo"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.webviewdemo.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

Related

Android Studio Not Finding Main Activity

I created a new class in my project called UserTypeSelection.java and wanted to set it as the main activity which launches when I run the app. I've changed the manifest file to contain an intent filter and also tried editing the configurations to set it as the default activity, however I keep receiving the error:
Error running app: The activity must be exported or contain an intent-filter
My manifest file is as follows:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.XXXXX.computerscienceinduction">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".UserTypeSelection" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<activity android:name=".RegistrationActivity"></activity>
<activity android:name=".MainActivity" />
<activity android:name=".LoginActivity" />
<activity android:name=".ProfileActivity" />
</application>
</manifest>
How can I resolve this issue. Any help is appreciated, thank you.
You are closing your activity xml tag before you have specified the IntentFilter.
Change your declaration to this.
<activity android:name=".UserTypeSelection" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
UserTypeSelection must be activity and it must be using intent filters you have not closed activity after intent filter it is closed before.
Try this,
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.XXXXX.computerscienceinduction">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".UserTypeSelection">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".RegistrationActivity"/>
<activity android:name=".MainActivity" />
<activity android:name=".LoginActivity" />
<activity android:name=".ProfileActivity" />
</application>
</manifest>

No launcher activity found in eclipse java android [duplicate]

This question already has answers here:
What does it mean "No Launcher activity found!"
(17 answers)
Closed 8 years ago.
I'm getting something that looks like this:
"No Launcher activity found!
The launch will only sync the application package on the device!"
I'm not sure how to fix this. My AndroidManifest looks like this:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.helloworld"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="20" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
</application>
</manifest>
Any help would be greatly appreciated. Thanks!
You need to add the activity to your manifest. For example, if your initial activity is called MainActivity:
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.helloworld.MainActivity"
android:label="Main Activity!" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Edit: The above shows an activity that is also being used as a launcher. Here is an example of a regular activity also being added to the manifest.
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.helloworld.MainActivity"
android:label="Main Activity!" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.helloworld.SecondActivity"
android:label="My second activity"
android:parentActivityName="com.example.helloworld.MainActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.helloworld.MainActivity" />
</activity>
</application>
You should add your acivities to the manifest file.
For Example:
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="<Package><ClassName>"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</applicaion>
Whenever you create Android Project in Eclipse it automatically generates a class called MainActivity which extends activity and generates Manifest file for you with a default entry of your MainActivity. Whenever you create a new class that extends Activity then you have to manually enter your activity in your manifest. You can change your your intent filter any time and you can set it to any activity and that activity will be your launcher activity of the app. This is a default Manifest file :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.test"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.test.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

Android: No Launcher activity found! Did check LAUNCHER

So most responses told me to check that there's an activity with the category set to LAUNCHER. I have 2 activities - one starting the other, and 2 .xml layout files (for each of the activities)- I get the "No Launcher activity found" when trying to run on emulator.
This is my manifest-file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="dk.orbliners.workout"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="19" />
<application
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" >
<intent-filter>
<action android:name="dk.orbliners.workout.MainActivity" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="SecondaryActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="dk.orbliners.workout.SecondaryActivity" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
For your main activity you need something like this:
<activity
android:name="MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

No Launcher Activity Found. The launch will only sync the application package on the device

I'm having an error in launching my test application, I'm a newbie on android development I hope you guys can help me.
Herewith is my manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.jhaydev.weirdgeeks"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.jhaydev.weirdgeeks.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.jhaydev.weirdgeeks.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.jhaydev.weirdgeeks.Menu"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.jhaydev.weirdgeeks.MENUA" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
I am getting following error:
[2013-11-11 22:59:16 - WeirdGeeks] Android Launch! [2013-11-11
22:59:16 - WeirdGeeks] adb is running normally. [2013-11-11 22:59:16 -
WeirdGeeks] No Launcher activity found! [2013-11-11 22:59:16 -
WeirdGeeks] The launch will only sync the application package on the
device!
Thanks.
Just Replace This line in your code:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

My app doesn't show on emulator, when I run the project

when I try to run the project it installs successfully on an emulator, but emulator does not show my app launcher icon in its app menu. but however it shows my app in installed apps in setting>applications>manage applications>all apps , so that means that an app was installed. but it didn't run.
Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.thenewboston.travis"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".Splash"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.thenewboston.travis.SPLASH" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Main"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.thenewboston.travis.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".Menu"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.thenewboston.travis.MENU" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
Make sure your starting activity has its intent-filter declared properly in your manifest to be shown in the launcher.
Assuming you want "Splash" to be your main activity change its declaration to this (specifically the intent-filter action)
<activity
android:name=".Splash"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Your intent filter action was not part of the android defaults (and what launchers normally look for). Only launchers that were designed to look for the action "com.thenewboston.travis.SPLASH" would see your activity
<activity
android:name=".Splash"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.thenewboston.travis.SPLASH" /> //try "android.intent.action.MAIN" here//
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

Categories

Resources