This question already has an answer here:
duplicate registration for activity "androidstutio"
(1 answer)
Closed 4 years ago.
We decided to make an intro/welcome screen to our app. The activity called Welcome Activity needs to be launched when user goes to the application for the first time. All other times Main Activity needs to be launched. That's how I've done it in Android Manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.google.android.gms.samples.vision.ocrreader"
android:installLocation="auto">
<uses-feature android:name="android.hardware.camera" />
<uses-permission android:name="android.permission.CAMERA" />
<application
android:name=".OcrApplication"
android:allowBackup="true"
android:fullBackupContent="false"
android:hardwareAccelerated="true"
android:icon="#drawable/icon"
android:label="Ingredient analysis"
android:supportsRtl="true"
android:theme="#style/Theme.AppCompat.NoActionBar">
<meta-data
android:name="com.google.android.gms.vision.DEPENDENCIES"
android:value="ocr" />
<activity android:name=".WelcomeActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:label="#string/title_activity_main"
android:windowSoftInputMode="stateHidden|adjustPan"
android:exported="true"
>
</activity>
<activity
android:name=".OcrCaptureActivity"
android:label="Read Text" />
<activity android:name=".ListResult" />
<activity android:name=".AllIngredients" />
<activity android:name=".IngredientDescription" />
<activity android:name=".Instruction" />
<activity android:name=".WelcomeActivity"> </activity>
</application>
However, there is an error - Duplicate registration for activity in this line:
Duplicate registration for activity happens when you register same Activity twice.
In your case you have registered WelcomeActivity twice. Once immediately after <application> tag and once at the very end.
Remove following re-registration line from end of your mainfest (before </application> tag)
<activity android:name=".WelcomeActivity"> </activity>
this problem usually occurs while there will be same name <activity tags multiple time.
In you code, found that, you used WelcomeActivity twice.
remove the <activity android:name=".WelcomeActivity"> </activity> (see at the last portion of your code, you will find that. just remove the line).
Related
I have one Gallery application (A) that binds to a service.
I have second transparent application (B) that just runs a service unbound and closes itself.
sometimes - when running application B from the launcher it also runs for a split of a second the application A. I see the layout of application A appears and disappear.
I suspect that something in the manifest is defined wrong : launchMode or taskaffinty.
any ideas?
<application
android:allowBackup="true"
android:label="#string/app_name"
android:icon="#mipmap/ic_launcher"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name="com.temp.tempApp.GalleryActivity"
android:theme="#style/AppTheme.NoActionBar"
android:icon="#mipmap/ic_launcher"
android:roundIcon="#mipmap/ic_launcher_round"
android:label="#string/app_label_gallery"
android:excludeFromRecents="true"
android:screenOrientation="portrait"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.temp.tempApp.MainActivity"
android:icon="#mipmap/ic_launcher"
android:roundIcon="#mipmap/ic_launcher_round"
android:launchMode="singleTask"
android:label="#string/app_label"
android:theme="#style/Theme.Transparent"
android:windowSoftInputMode="stateHidden|adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name="com.temp.tempApp.MainService" android:enabled="true"
android:exported="false">
</service>
Found the answer, one of the following fixed it:
1. add to each activity specific afinity value "android:taskAffinity="com.example.MainActivity""
2. different icons for the 2 activities.
hope it helps somebody in the future
Unfortunately when I try to run my wallpaper I get an error message saying Permission Denial starting Intent and requires android.permission.BIND_WALLPAPER but I can't seem to figure out why. My manifest looks like the following:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.package">
<uses-feature android:name="android.software.live_wallpaper" />
<uses-permission android:name="android.permission.SET_WALLPAPER" />
<application
android:exported="true"
android:icon="#drawable/icon"
android:label="#string/app_name"
android:permission="android.permission.BIND_WALLPAPER">
<service
android:name="WallpaperService"
android:icon="#drawable/icon"
android:label="#string/app_name"
android:permission="android.permission.BIND_WALLPAPER">
<intent-filter>
<action android:name="android.service.wallpaper.WallpaperService" />
</intent-filter>
<meta-data
android:name="android.service.wallpaper"
android:resource="#xml/livewallpaper" />
</service>
<activity
android:name=".WallpaperSetClass"
android:exported="true"
android:permission="android.permission.BIND_WALLPAPER"
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>
The live wallpaper does run perfectly if I set it through the live wallpaper part of my phone, but I would like to have a settings area as well to be able to open in which I can't.
At the moment my settings class is basically empty containing just an onCreate function and a layout with a button.
Is there something I'm missing? I seem to have the permissions along with android:exported
Turns out I had
android:permission="android.permission.BIND_WALLPAPER"
In the wrong spot, it should be in the service tag, and only have ONE, having multiple will break it.
first timer here (both in development and posting in SO). I've used idunnololz to create an animated listview for a simple reference app I'm trying to make. It's turned out really well, but after I've created it, when I run the app to test it, it now runs as AnimatedExpandableListView both in the ActionBar title and in the app drawer. I've searched here and found that you can get the app to launch with a different activity by editing the AndroidManifest.xml, so I verified that I'm pointing to my MainActivity class:
<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>
I presume this may be an issue with the MainActivity class, but maybe there's something here that I'm missing?
I found my answer here:
Android: App name shows the first page name, not the app name
<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 **NEED #string/app_name HERE**>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
I have a manifest with its label declared so the launcher label is different from the Main Activity (the one that is launched at start).
It was working fine, but today I saw on a friends phone it took the activity's label instead.
I have no idea what could be happening.
If it is of any help, the phone was a Motorola Razr.
Here's the relevant portion of the manifest:
<application
android:name="com.app.eventiame.EventiameApp"
android:allowBackup="true"
android:icon="#drawable/logo"
android:label="#string/app_name"
android:theme="#style/Theme.Sherlock.Light.DarkActionBar" >
<activity
android:name="com.app.eventiame.MainActivity"
android:label="#string/title_activity_main" >
<intent-filter android:label="#string/app_name">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
You have wrote
android:name="com.app.eventiame.EventiameApp"
instead you can just specify your app name here as below
android:name="EventiameApp"
I have added my third class to my package, and I want to add it to my androidmanifest.xml file. I have added the second class easily with no problem, but I'm stuck with the third one.
When do I try to add the third activity:
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.metoo.codedetective.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.metoo.codedetective.Etelaateomoomi">
<activity android:name=".Factoryreset">
</activity>
</activity>
</application>
</manifest>
I get The element must be a direct child of the element.
What should I do?
Please correct the code and post it.
thanks for advance
In
<activity android:name="com.metoo.codedetective.Etelaateomoomi">
<activity android:name=".Factoryreset">
</activity>
</activity>
remove <activity android:name=".Factoryreset"> </activity> because this is an activity in an activity which is not allowed.
I think you need this:
<activity android:name="com.metoo.codedetective.Etelaateomoomi.Factoryreset">
</activity>
Remove the following lines that represent an activity inside another activity.
<activity android:name=".Factoryreset">
</activity>