When I run my application, it starts up the activity_main.xml file instead of the login.xml file. When I go into my AndroidManifest, what do I change to make it so that the login file runs on start up? Thanks in advance!
Here is the AndroidManifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.dashboardactivity"
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.example.dashboardactivity.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>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:label="#string/app_name"
android:name=".DashboardActivity" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- Login Activity -->
<activity
android:label="Login Account"
android:name=".LoginActivity"></activity>
<!-- Register Activity -->
<activity
android:label="Register New Account"
android:name=".RegisterActivity"></activity>
</application>
<!-- Allow to connect with internet -->
<uses-permission android:name="android.permission.INTERNET" />
NOTE:After editing the manifest looks like this:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.dashboardactivity"
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.example.dashboardactivity.MainActivity"
android:label="#string/app_name" >
</activity>
</application>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:label="#string/app_name"
android:name=".DashboardActivity" >
</activity>
<!-- Login Activity -->
<activity
android:label="Login Account"
android:name=".LoginActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- Register Activity -->
<activity
android:label="Register New Account"
android:name=".RegisterActivity"></activity>
</application>
<!-- Allow to connect with internet -->
<uses-permission android:name="android.permission.INTERNET" />
When I run the app now, I get this error in the Console:
[2013-08-30 13:31:32 - DashboardActivity] Starting activity com.example.dashboardactivity.LoginActivity on device HT18YMA05067
[2013-08-30 13:31:32 - DashboardActivity] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.dashboardactivity/.LoginActivity }
[2013-08-30 13:31:32 - DashboardActivity] ActivityManager: Error type 3
[2013-08-30 13:31:32 - DashboardActivity] ActivityManager: Error: Activity class {com.example.dashboardactivity/com.example.dashboardactivity.LoginActivity} does not exist.
I have created a LoginActivity.java class so I don't know what's wrong.
what do I change to make it so that the login file runs on start up?
You don't really change the xml file that is loaded, you change the Activity that is the Launcher. You do that in the <activity> tag of the Activity that you want to change. Like you have here
<activity
android:label="#string/app_name"
android:name=".DashboardActivity" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
delete that Intent filter from that <activity> tag and add it to the LoginActivity
<activity
android:label="#string/app_name"
android:name=".DashboardActivity" >
</activity>
<!-- Login Activity -->
<activity
android:label="Login Account"
android:name=".LoginActivity"></activity>
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
When I run my application, it starts up the activity_main.xml file instead of the login.xml file.
The layout.xml that is displayed is determined by what you use in your Activity in setContentView(). You could change that but that's probably not what you want. Its probably not just that you want a different layout but you want the LoginActivity to start when your app is opened and not the MainActivity.
You move
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
To the activity you want to run first, in this case, login.
this code causes for start activity
but it does not belong to xml file that are chosen by Activity Classes what ever xml (the layout file ) you have set in activity will be open.
add this code to that activity you want to start with but it must appear only once in manifest for only one activity
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
In your case
<!-- Login Activity -->
<activity
android:label="Login Account"
android:name=".LoginActivity">
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Related
When I install my app using a file explorer on my tv, I can run it and everything but I do not know how to create an icon that will sit on the home screen of the tv
Here is my AndroidManifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sony.omgandroid" >
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme" >
<activity
android:name=".FullscreenActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="#string/app_name"
android:theme="#style/FullscreenTheme" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
It utilizes the android:banner in the AndroidManifest on the application tag.
<application
android:name=".ExampleApp"
android:banner="#drawable/app_banner"
android:theme="#style/AppTheme"
You need add in AndroidManifest.xml file
android:banner android:icon android:logo and android.intent.category.LEANBACK_LAUNCHER
example:
<activity
...
android:banner="#mipmap/ic_launcher"
android:icon="#mipmap/ic_launcher"
android:logo="#mipmap/ic_launcher">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
</intent-filter>
</activity>
i have 2 activities AndroidSlite.java and SqLiteAdapter.java.. my manifest.xml file is given below.it shows No launcher activity found .while running
please help me with the code
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.cerebtec.androidsqlite"
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" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<activity android:name="AndroidSQLite"></activity>
</application>
</manifest>
You have to enclose the intent filter around the launcher activity, in order to declare your launcher activity. E.g.
<activity android:name="AndroidSQLite"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
this way you are telling android that the launcher activity is AndroidSQLite
Use :
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
in writing a widget and after i tried to add a setting activity for my widget , i got the error "No Launcher activity found!"
this is my AndroidManifest.xml :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.persianweather"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<receiver android:name="com.example.persianweather.Main" >
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<!-- This specifies the widget provider info -->
<meta-data
android:name="android.appwidget.provider"
android:resource="#xml/widget" />
</receiver>
<activity
android:name="com.example.persianweather.SettingActivity"
android:label="#string/title_activity_setting" >
<intent-filter >
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
</intent-filter>
</activity>
</application>
No Launcher activity found! means that you not mentioned any activity on launching the application. Try to add these lines in manifest. To specify these MAIN and LAUNCHER in the the intent filter for the activity you want to start on launch like:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
Note: Multiple action tags in a single intent-filter tag will also cause the same error.
Make your SettingActivity as launcher activity, Only then you will be able to proceed further,
<activity
android:name="com.example.persianweather.SettingActivity"
android:label="#string/title_activity_setting" >
<intent-filter >
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
I've developed a launcher. In my device, there are 3 launcher with my application and the default launcher of Android. If I have not launched my application before, when I press home, my application appears on the launcher list. So, when I touch my launcher, it occurs error because of I didn't start it before. What can I do to solve this problem?
My manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.comeks.deneme"
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.comeks.deneme.Main"
android:label="#string/app_name"
android:screenOrientation="landscape"
android:excludeFromRecents="true" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:label="#string/app_name"
android:name=".main.java"
android:excludeFromRecents="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>
</application>
</manifest>
What is the name of the file of your second activity?
main.java.java?
Do you even have two different activities?
Following this: http://developer.android.com/training/basics/firstapp/starting-activity.html I am confused when editing the Android Manifest.xml file. It says that the file should contain this:
<application ... >
<activity android:name="com.example.myapp.DisplayMessageActivity" />
...
</application>
My android manifest.xml looks like this:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.nick.myfirstapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="4"
android:targetSdkVersion="15" />
<application android:label="#string/app_name">
<activity android:name="com.nick.myfirstapp.DisplayMessageActivity" />
...
</application>
</manifest>
and when I run the app everything goes fine except it says : "No Launcher activity found!
The launch will only sync the application package on the device!" Is this something missing from the android manifest.xml file?
declare Your Activity in AndroidManifest.xml as for Showing In Launcher as:
<application android:label="#string/app_name">
<activity android:name="com.nick.myfirstapp.DisplayMessageActivity" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
see for more info how we set an activity which so in Launcher :
http://developer.android.com/reference/android/content/Intent.html
http://developer.android.com/reference/android/app/Activity.html
You need to change you manifest to the following. Doing this will tell Android that you want this Activity to be displayed in the Launcher using your icon.
<application android:label="#string/app_name" android:icon="drawable icon resource here">
<activity android:name="com.nick.myfirstapp.DisplayMessageActivity" android:label="Your Label">
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
In the docs the used ... to show that your normal code goes here. What you're doing is fine for non-launcher Activities.
You are missing the launcher intent and therefore the app finds no activity to launch at the start.
You need to lay out the activity like so:
<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>
package="com.example.myfirstapp"
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.myfirstapp.DisplayMessageActivity"
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>