how to add an activity to the android manifest - android

How do I add:
<activity
android:name=".MainActivity2"
android:label="#string/title_activity_main">
</activity>
into the AndroidManifest.xml
which currently looks like this:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.bac"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="10"
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="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
I'm fairly new to android programming and have yet to figure out a lot of stuff about transferring between pages and other things like that. Thanks for any help you give!

Just Add another Activity tag under your application tag
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.bac"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="10"
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="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity2"
android:label="#string/title_activity_main">
</activity>
</application>
</manifest>
If you are new to android and trying to understand about manifest
Have a look at ANDROID-DEVELOPERS-SITE ..... Click here
Have a look at youtube-tutorial too hope this helps
It has all the information you need to get started knowing more about the manifest file

You need to add your Activity inside Application tag.
The activity is the child node of the application node. The multiple activities can specify by multiple nodes of activity.
Read this : manifest-intro
your manifest will be look like
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.bac"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="10"
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="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- Add your activities here -->
<activity
android:name=".MainActivity2"
android:label="#string/title_activity_main">
</activity>
</application>
</manifest>

you can add any number of activity inside your application tag in AndroidManifest.xml.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.bac"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="10"
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="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- activity goes here-->
<activity
android:name=".MainActivity2"
android:label="#string/title_activity_main">
</activity>
</application>
</manifest>

to add an activity to the Manifest , just copy the content of the exesting activity in the manifest and remove the intent filter like this
---the original
<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>
---the new
<activity
android:name=".yourNewActivityName"
android:label="#string/app_name" >
</activity>
you need add this in the application tag.
you need to change the android:name property to your new activity's name

Related

Android Manifest . The markup in the document following the root element must be well formed

I have looked through other questions regarding the same problem but was unable to find a helpful solution. Here is my xml . What is wrong with it?
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.projextxy"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="21" />
<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="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".LogInActivity"
android:label="#string/title_activity_log_in"
android:parentActivityName="com.example.projextxy" >
</activity>
<activity
android:name=".SignUpActivity"
android:parentActivityName="com.example.projextxy"
android:label="#string/title_activity_sign_up" >
</activity>
</application>
You missed the last manifest tag </manifest> after your application tag
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.projextxy"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="21" />
<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="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".LogInActivity"
android:label="#string/title_activity_log_in"
android:parentActivityName="com.example.projextxy" >
</activity>
<activity
android:name=".SignUpActivity"
android:parentActivityName="com.example.projextxy"
android:label="#string/title_activity_sign_up" >
</activity>
</application>
</manifest>

Android application crashing, manifest issue

Heloo! I am creating an application in Android. I have declared all my activities in Android manifest, including the main one, and when i start it, it says that the activity i have selected as launcher does not exist:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.boacterapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="18" />
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="22" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="MainPage"
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="AboutPage"
android:label="title_firskljt_activity">
</activity>
<activity
android:name="RecentSightingsPage"
android:label="title_first_activity">
</activity>
</application>
</manifest>
I have been stuck here for a while, so i'm kindly asking that you could help me identity if i have a problem in my manifest. Thank you in advance!
Make sure MainPage activity is in package "com.example.boacterapp".
Another option: replace short name:
android:theme="#style/AppTheme" >
<activity
android:name="MainPage" <----------------- short
android:label="#string/app_name" >
<intent-filter>
With long name that makes up the full class name of your activity:
android:theme="#style/AppTheme" >
<activity
android:name="com.bla.bla.MainPage" <------------- long
android:label="#string/app_name" >
<intent-filter>
Add "." (dot) before MainPage
as
android:name=".MainPage"
Same for others,so rewrite your manifest as
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.boacterapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="18" />
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="22" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainPage"
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=".AboutPage"
android:label="title_firskljt_activity">
</activity>
<activity
android:name=".RecentSightingsPage"
android:label="title_first_activity">
</activity>
</application>
</manifest>
<activity android:name="MainPage"
should be:
<activity android:name=".MainPage"
assuming that your MainPage activity is in the package com.example.boacterapp. If not, you need to provide the fully-qualified name of the MainPage app.
Activity name should have dot prefix, change activity name to .MainPage. Make sure it is inside com.example.boacterapp package

I got ,The markup in the document following the root element must be well-formed. styles.xml, on auto generated code

I am learning Android Development and got this error in AndroidMainfest.xml
The markup in the document following the root element must be well-formed. styles.xml
The codes below is generated automatically.
Original
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.incomeexp"
android:versionCode="1"`enter code here`
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.incomeexp.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>
Added
<manifest xmlns:android="http://schemas.android.com/apk/res/android" >
<application>
<activity android:name=".DisplayMessageActivity"
android:label="#string/title_activity_display_message"
android:parentActivityName="com.example.incomeexp.MainActivity">
<meta-data android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.incomeexp.MainActivity" />
</activity>
</application>
</manifest>
Remove the one added. Have the below . Check your package name in manifest and activities. Clean and build
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.incomeexp"
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.incomeexp.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>
<activity android:name=".DisplayMessageActivity"
android:label="#string/title_activity_display_message"
android:parentActivityName="com.example.incomeexp.MainActivity">
<meta-data android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.incomeexp.MainActivity" />
</activity>
</application>
</manifest>

launch errors fail to install

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.bpi.mygears"
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.bpi.gears.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>
<activity
android:name="com.bpi.gears.home"
android:label="#string/title_activity_home" >
</activity>
<activity
android:name="com.bpi.gears.profile"
android:label="#string/title_activity_profile" >
</activity>
</application>
</manifest>
this is my manifest feel free to check it and tell me where im wrong i would help a lot if you need to see all i can show you all my project has no error so im having a difficult time finding where im wrong...
I think you have some problems with your naming. Your package name is "com.bpi.mygears" and you are looking for activities that are com.bpi.gears. Your activities can just be named relative to the package. It should probably be more like this:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.bpi.mygears"
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=".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>
<activity
android:name=".home"
android:label="#string/title_activity_home" >
</activity>
<activity
android:name=".profile"
android:label="#string/title_activity_profile" >
</activity>
</application>
</manifest>
Assuming your stuff is in com.bpi.mygears. Otherwise, make that first line
package="com.bpi.gears" if your stuff is in gears.

Android: No Launcher activity found, no problems in Manifest

Here's my AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.fionaheiss.shovelshovel"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="13"
android:targetSdkVersion="15" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity android:label="DisplayMap"
android:name="com.seanheiss.shovelshovel.DisplayMap"
android:theme="#android:style/Theme.Black.NoTitleBar"
android:configChanges="keyboard|keyboardHidden|orientation" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
I've tried the "name" field as above and just as ".DisplayMap". It is definitely spelled correctly. Could it be because I'm using Slick2D? The file DisplayMap.java extends BasicGame from the Slick2D engine, and has a main method. Maybe it's not an actual activity or something, but I'm not sure.
Any ideas? Thank you very much!
You forgot to close the Activity tag:
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity android:label="DisplayMap"
android:name="com.seanheiss.shovelshovel.DisplayMap"
android:theme="#android:style/Theme.Black.NoTitleBar"
android:configChanges="keyboard|keyboardHidden|orientation" > // Also fix this here
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity> // <-- here
</application>
Good Morning,
You have to close the <activity> tag after the <intent-filter>
<activity >
<intent-filter>
-------------------
------------------
</intent-filter>
</activity>

Categories

Resources