AndroidManifest.xml with multiple application tags

I am very new to Android programming, and I am trying to understand why my application is forcibly closed by the click of a button. I narrowed it down to a few things.

One question; Is it possible to have more than one tag <application>in an xml manifest?

Here is my code:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.dummies.android.beergoggles"
  android:versionCode="1"
  android:versionName="1.0">
<uses-sdk android:minSdkVersion="8" />

<application android:icon="@drawable/icon" android:label="@string/app_name">
    <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="Result" android:label="@string/app_name">        </activity>
</application>
<application android:name="MyApp" 
   android:icon="@drawable/icon" 
   android:label="@string/app_name2"></application>

I do research, but found only a vague message about creating a new manifest file for a new application. The MyApp application is just an application for a “global variable,” since I assume that there is no way to do this without a new application.

Here is the code for MyApp if it helps:

import android.app.Application;

public class MyApp extends Application{

public static int resultCount;

public int getCount(){
    return resultCount;
  }
public void setCount(int c){
    resultCount = c;
}
}

Any help would be greatly appreciated.

+5
3

, Application Application.

, <application>, <application> ( ).

<application android:icon="@drawable/icon" android:label="@string/app_name" android:name:"com.mypackage.MyApp"> <!-- Added the android:name -->
    <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="Result" android:label="@string/app_name">        </activity>
</application>

.

+8

.

<manifest> <application> , .

+17

Only the elements 'manifest' and 'application' are required, each of them must be present and can appear only once. Most other people can meet many times or not at all, although at least some of them must be present in the manifest in order to achieve anything meaningful.

0
source

All Articles