I made a android app and it worked very well, but there are two icons in my device screen. I think it could be a AndroidManifest problem. Any idea what it could be?
This my AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="pk.aeh.ideos.taa"
android:versionCode="1"
android:versionName="1.0" >
<application
android:icon="#drawable/icon"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar" >
<activity
android:name=".Ghinho_congviecActivity"
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="Nhap_congviecActivity"></activity>
<activity android:name="Sua_congviecActivity"></activity>
<activity
android:name=".Quizzes"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".PlayGame" />
<activity android:name=".Result" />
</application>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
This could be because you have declared two activities as MAIN and LAUNCHER
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
in your Androidmanifest.xml file. You need to have only one activity with these intent filters so that when the app is installed the system will know which activity is to be used as the main launcher activity.
It is. You have two of these:
<category android:name="android.intent.category.LAUNCHER" />
Get rid of the one you don't want.
You need to make these changes to your Manifest.xml
<activity
android:name=".Ghinho_congviecActivity"
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="Nhap_congviecActivity"></activity>
<activity android:name="Sua_congviecActivity"></activity>
<activity
android:name=".Quizzes"
android:launchMode="singleTask">
</activity>
I am assuming that the Activity with the attribute android:label="#string/app_name" might be your main activity.
It could be because you have changed your package name and installed it twice with different package names.
Remove the intent filter of one the activity and it would work perfectly.!
Your manifest file should only have one activity with below Intent Filter, Activity which you want to have an icon:
<intent-filter>
<action android:name = "android.intent.action.MAIN" />
<category android:name = "android.intent.category.LAUNCHER" />
</intent-filter>
Based on your description, it sounds like two activities have this line. Check your Manifest...
You can declare only one Intent filter in the activity, on AndroidManifest.
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
If you used two or more intent filter in AndroidManifest, then you will have display 2 app icon, So remove it & set one intent filter.
I hove this is usedful to you.
Related
aid with this example at Return back to MainActivity from another activity
I copy that codes as follow,
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="15" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Activity1"
android:label="#string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.ACTIVITY001" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".Activity2"
android:label="#string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.ACTIVITY002" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".Activity3"
android:label="#string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.ACTIVITY003" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
So many statements: action android:name="android.intent.action.MAIN"; if I would use their class path to instead of them, they can also do the job. what's different from these two ways?
setClass() is a explicit declaration, setAction() is a implicit declaration. It will find your target action im manifest.xml.
If the intent-filter with “android.intent.action.MAIN”, there would more entryance of your application, also you can found more icon in launcher.
its wrong
<action android:name="ACTIVITYNAME FOR INTENT" />
<category android:name=""/> // android.intent.action.DEFAULT or android.intent.action.MAIN
android.intent.action.MAIN is given to the activity wich is going to launch at first and
android.intent.action.OTHER to the rest of the activities getting called by other activities
Your application will refer to the manifest to fetch the activity for first launch , havin MAIN in it
I'm trying to combine android manifest files from 2 plugins in Unity, but there are two activities with the same intent-filter and I can only get 1 or the other to work at the same time....
Of the 2 conflicting activities, whichever is on top in the manifest file is the one that will work. So if activity from manifest #1 is on top, plugin #1 will work but not #2, and vice versa.
The two conflicting activities are:
<activity
android:name="com.devfo.andutils.DevfoUnityPlayerActivity"
android:label="#string/app_name"
android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
And:
<activity android:name="com.qualcomm.QCARUnityPlayer.QCARPlayerProxyActivity"
android:label="#string/app_name" android:screenOrientation="portrait"
android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
is there any way I can merge the two and get them to work from the same app? I'm using Unity 3d.
For example in the manifest where you want to use only the first activity as launcher you have to add this 2 modifications:
At the beginning of the manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
And for the activity for which you want to remove the intent filter add this code:
<activity android:name="com.qualcomm.QCARUnityPlayer.QCARPlayerProxyActivity"
android:label="#string/app_name" android:screenOrientation="portrait"
android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
<intent-filter tools:node="removeAll">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
The important part is to add the tools:node="removeAll" attribute in the intent-filter tag
Declare your manifest header like this:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
And then add one of the following appropriate attributes to the relevant Activity(s):
tools:merge="override"
tools:merge="remove"
Slightly different to #amarkovits answer, I've found success with:
<activity android:name="com.qualcomm.QCARUnityPlayer.QCARPlayerProxyActivity"
android:label="#string/app_name" android:screenOrientation="portrait"
android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen"
tools:node="merge">
<intent-filter tools:node="remove"> ...
which I believe will try to merge it first, then replaces just the intent filter causing both Icons on the launcher screen
The Activity that has this intent-filter:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
is the main Activity that will start on application start up, you can't make both activities work at the same time.
what you should do is let only one Activity ( your main one have this filter) and leave the other one without it.
the second Activity will also be part of the application, but it will not be the first Activity you will see. You can start it by using the startActivity() method.
I have done this, the solution is that when you have multiple flavors, like
1. flavorA,
2. flavorB
and main application id is - com.android.vivek
and main flavorA is using com.android.vivek
and second flavorB is using com.android.vivek.flavorb
flavorA's manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.android.vivek">
<application xmlns:tools="http://schemas.android.com/tools"
android:allowBackup="true"
android:icon="#mipmap/flavorA_ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme"
tools:replace="android:icon" />
<activity
android:name=".ActivitySplash"
android:label="#string/app_name"
android:launchMode="singleTop"
android:screenOrientation="portrait"
tools:node="replace">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
then simply flavorB's manifest mention like below
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.android.vivek">
<application xmlns:tools="http://schemas.android.com/tools"
android:allowBackup="true"
android:icon="#mipmap/flavorB_ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme"
tools:replace="android:icon" />
<activity
android:name=".flavorB.SecondActivity"
android:label="#string/app_name"
android:launchMode="singleTop"
android:screenOrientation="portrait"
tools:node="replace">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ActivitySplash"
android:label="#string/app_name"
android:launchMode="singleTop"
android:screenOrientation="portrait">
<intent-filter tools:node="remove">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
when you run flavorA or flavorB then it will work fine
My AndroidManifest.xml is like the followings:
<application android:label="droid VNC server" android:icon="#drawable/icon"
android:name="MainApplication" android:debuggable="true">
<activity android:name=".MainActivity" android:launchMode="singleInstance"
android:label="#string/app_name" android:icon="#drawable/icon">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="org.onaips.vnc.ACTIVITY_UPDATE" />
</intent-filter>
</activity>
</application>
I already set the following two lines:
Why I still get the errors
No Launcher activity found
The launch will only sync the application package on the device
Thanks
Your intent-filter tag in xml file should exactly be like this:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
Place it inside <activity> tag and you should be ok
Remove the line
<action android:name="org.onaips.vnc.ACTIVITY_UPDATE" />
Because there are 2 similar lines, the 2nd line is usually considered. (Ambiguity). So just remove that line, and you will see the app in the launcher!
Newb question. How can you know what the main launch Activity is? Learning Android.
Assuming this is for your code, check out the manifest.xml and look for this element:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
It should be contained within <Activity> ... </Activity> tags, and that Activity is the one that a user can launch from their phone.
You have to put the right intent tag on the activity in the manifest:
<activity android:name=".SomeActivity"
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 main activity can be considered the one which handles the initial screen of the application you're creating.
?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="clustering.android"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="10"
android:targetSdkVersion="11" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<application
android:icon="#drawable/gene_launcher"
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=".yourSubActivity" android:label="#string/<ActivityName>"> </activity>
...list of other activities...
</application>
</manifest>
The main activity can be found and set in AndroidManifest.xml; look for
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
The <activity> with that action is the main activity (is the entry point for the app).
You can look into AndroidManifest.xml in your porject
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
This will help you to find Launch activity.
I am trying to go back to a previous activity using intents.
The problem I have is with my main page, it is the page that launches the app so when I try to put the name android.intent.action.MAIN as my intent, it gives me the option to open all the apps.
What should I do to fix this? How can I rename my activity name?
Thanks
Here is my Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.AssaultAlarm.full" android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="5" />
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"></uses-permission>
<uses-permission android:name="android.permission.READ_CONTACTS" />
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".AssaultAlarmActivity"
android:screenOrientation="portrait" android:theme="#android:style/Theme.NoTitleBar"
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=".Info" android:screenOrientation="portrait"
android:theme="#android:style/Theme.NoTitleBar" android:label="#string/app_name">
<intent-filter>
<action android:name="com.AssaultAlarm.INFO" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name=".Settings" android:screenOrientation="portrait" android:permission="android.permission.READ_CONTACTS"
android:theme="#android:style/Theme.NoTitleBar" android:label="#string/app_name">
<intent-filter>
<action android:name="com.AssaultAlarm.SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
This is how I want to call it
Intent info = new Intent("AssaultAlarmActivity.class");
startActivity(info);
If you want to go to previous activity you can just finish current activity. You will automatically go to previous activity in stack but if you want to go specific activity you can use following.
Why you are not using explicit intent.
Intent info = new Intent(CallingActivity.this,AssaultAlarmActivity.class);
startActivity(info);
If you don't want to use explicit intent you may add new intent filter for your activity
<activity android:name=".AssaultAlarmActivity"
android:screenOrientation="portrait" android:theme="#android:style/Theme.NoTitleBar"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="MyAction" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
and
Intent info = new Intent("MyAction");
startActivity(info);
If you want to rename your activity you will do it as follow
<activity-alias android:name="AlternateName"
android:targetActivity=".AssaultAlarmActivity"
/>