android configChange:orientation and manifest does not work - android

I have used a Web view. which loads webpage. When i orientation is changed it reloads. I want to stop reloading. I did following change in manifest XML File.
It works in android 2.2 but not in android 4.0. I am a beginner can any one provide solution.
My Manifest.xml is;
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="application.eag"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET" />
<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"
android:configChanges="orientation|screenSize|keyboardHidden">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

<activity
android:name=".ActivityName"
android:configChanges="orientation|screenSize|keyboardHidden"/>
Use screenSize for newly version. orientation might not be supported in some version, need to use screenSize for configChanges

This one worked for me:
<activity android:name=".YourActivity"
android:configChanges="orientation|screenSize|keyboardHidden">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

I am using like the following and it works for me.
<activity
android:name="com.myapp.MainActivity"
android:configChanges="orientation|keyboardHidden"/>

Made changes as answered by Avadhani Y
1) Added following in manifest
<activity
android:name=".ActivityName"
android:configChanges="orientation|screenSize|keyboardHidden"/>
2) changed manifest as
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17"/>
3) in project.properties set the following value
# Project target.
target=android-13

Use your activity like this ...
<activity
android:name=".UserLoginActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:screenOrientation="unspecified" >
</activity>

I couldn't get any of these to work, but then I got it (not sure what was going on but thought I'd elaborate on other answers to save people time). I found the below to work for my app (1 line in your manifest INSIDE the tag, for the activity you want this behavior for. I also discovered it completely depends on your app on what you need here. For a complete list see http://developer.android.com/guide/topics/manifest/activity-element.html#config
And by 'doesn't work', I mean the onDestroy() method got called every time I rotated my device. See Why not use always android:configChanges="keyboardHidden|orientation"? for reasons you likely shouldn't use this.
Manifest.xml:
<activity
android:name="com.example.MainActivity"
android:label="#string/app_name"
android:launchMode="singleTop"
android:configChanges="orientation|screenSize"
>

Related

Android Studio doesn't recognize MainActivity though declared in AndroidManifest.xml

After pausing with work on an Android Studio project for a while, and then coming back and adding it to SVN, I can't get the project to run anymore; it seems to me that the original AndroidManifest.xml was probably lost due to a lack of proper "SVN ignore" rules, and as I created a new Android Studio project on a new machine, updated it from SVN and later commited (and also unfortunately already updated on the other machine I work on), it seems that SVN used the newer manifest file and maybe other files needed for a proper build of the project.
Besides the fact that in the current manifest file, there are several activites missing that I'll have to try to reconstruct there, I now have the problem that I always get the "Default Activity not found" error when trying to build. When I set it to .MainActivity (which is absolutely present in app/src/main/java/com.example.bla.logintest) it says "The activity 'MainActivity' is not declared in AndroidManifest.xml" and thus doesn't compile.
My manifest file now looks like this:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.bla.logintest" >
<uses-permission android:name="android.permission.READ_PHONE_STATE">
<application
android:allowBackup="true"
android:icon="#mipmap/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=".EditDB"
android:label="#string/title_activity_edit_diags"
android:parentActivityName=".MenuActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.bla.logintest.MenuActivity" />
</activity>
<activity
android:name=".EditAnswers"
android:label="#string/title_activity_edit_questions"
android:parentActivityName=".MenuActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.bla.logintest.MenuActivity" />
</activity>
</application>
</uses-permission>
</manifest>
Note: I already tried the solutions in [this similar question][1].
[1]: Default Activity not found in Android Studio "this similar question". Rebuilding and invalidating the cache doesn't get me anywhere. I also added
sourceSets {
main {
manifest.srcFile 'src/main/AndroidManifest.xml'
}
to my build.gradle, and this also didn't change anything.
I am aware that the parent to the other 2 activities is still missing and wanted to work on that problem next, but first wanted to have a working default activity.
Do you have any suggestions what I could try? I'm using Android Studio 1.3.2.
This should solve your problem.
You shouldn't write the tag inside the tag.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.bla.logintest" >
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<application
android:allowBackup="true"
android:icon="#mipmap/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=".EditDB"
android:label="#string/title_activity_edit_diags"
android:parentActivityName=".MenuActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.bla.logintest.MenuActivity" />
</activity>
<activity
android:name=".EditAnswers"
android:label="#string/title_activity_edit_questions"
android:parentActivityName=".MenuActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.bla.logintest.MenuActivity" />
</activity>
</application>
</manifest>

stuck application at the same view even the class of that view is removed

Im working with an android application ,even if I change the names of classes at AndroidManifest.xml the application still work and installing on the tablet but the weird thing that even I removed the launcher activity from the manifest I still got it when I run the app the same xml view !!!
As an indication Im using Maven too.
I think the problem comes from Maven
this is my manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.myapps.android"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
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.myapps.android.project.login.Connection"
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.myapps.android.project.login.Connection" >
</activity>
</application>
</manifest>
I tried:
removing the R file
undeploying the application from the device with this comand:
mvn android:undeploy -Pandroid-15 -Dandroid.device=usb
Uninstall the application manually from the device
removing maven android folder from .m2/repository
I still got the same activity while deploying the application to the device
First of all, there is a little problem in your manifest: you are defining the same activity twice:
<!-- First time definition of "com.myapps.android.project.login.Connection" -->
<activity android:name="com.myapps.android.project.login.Connection"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- Second definition of "com.myapps.android.project.login.Connection" -->
<activity android:name="com.myapps.android.project.login.Connection" >
you should remove the second one, it doesn't make sense to have a duplicated definition.
Did you change the Connection.java and/or Connection.xml and nothing hapened?

Android app is shown as not compatible in play store

I have published a new update of my App. After publishing it got a warning like "Warning: Your active APK supports less devices then the previous APK. Some users won't get the update."
So i've compared the details of the current and the prior APK. There is only one difference: The new one has the additional entry "Native Platform: simple-xml.2.6.9.jar".
Do you think that there is a problem with it? Acutally i've intergrated the .jar into my android project.
Additionally, the developer console shows me that the app is now compatible with 0 devices... if i search for a certain device i get a notice that it's because of my manifest settings.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="edu.kit.aifb.nukit"
android:versionCode="8"
android:versionName="#string/app_versionName" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="17" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/Theme.KIT.Styled"
android:allowBackup="true" >
<activity
android:name="edu.kit.aifb.nukit.gui.SplashScreenActivity"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:theme="#style/Theme.Sherlock.Light.NoActionBar"
android:clearTaskOnLaunch="true" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="edu.kit.aifb.nukit.gui.ChooseCourseActivity"
android:screenOrientation="portrait"></activity>
<activity
android:name="edu.kit.aifb.nukit.gui.QuestioningAndVotingActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden"></activity>
<activity
android:name="edu.kit.aifb.nukit.gui.AnswerQuestionActivity"
android:screenOrientation="portrait"></activity>
<activity
android:name="edu.kit.aifb.nukit.gui.ShowResultsActivity"
android:screenOrientation="portrait"></activity>
<activity
android:name="edu.kit.aifb.nukit.gui.ImpressumActivity"
android:screenOrientation="portrait"></activity>
<activity
android:name="edu.kit.aifb.nukit.gui.LicensesActivity"
android:screenOrientation="portrait"
android:hardwareAccelerated="false"></activity>
<activity
android:name="edu.kit.aifb.nukit.gui.survey.SurveyListActivity"
android:screenOrientation="portrait"></activity>
<activity
android:name="edu.kit.aifb.nukit.gui.survey.QuestionActivity"
android:screenOrientation="portrait"
android:parentActivityName=".SurveyListActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".SurveyListActivity" />
</activity>
<activity
android:name="edu.kit.aifb.nukit.gui.survey.SurveyResultsActivity"
android:label="SurveyResultsActivity"
android:parentActivityName=".SurveyListActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".SurveyListActivity" />
</activity>
</application>
if i install the apk directly on my device, it works fine.
This should probably be due to changes done in your Android Manifest relating to max and min sdk versions
<uses-sdk android:minSdkVersion="integer"
android:targetSdkVersion="integer"
android:maxSdkVersion="integer" />
If this SDK version range has been altered, your new updated app might support lesser number of devices.
Alright, i fixed it.
The problem was that actualy only the SurveyLib.jar is using simple-xml-2.6.9.jar and the simplexml.jar was included within the SurveyLib.jar. So i think there was a problem dexing the simplexml.jar within surveylib.jar.
i've created the surveylib.jar again without simplexml.jar but included the simplexml.jar to the libs folder of my app.
now it works fine. thanks to you all for your help.

Duplicate attribute error in AndroidMainfest.xml while adding a new Activity

I was making a simple text field and 'send' button to display whatever the user typed in the text field. The program is completely illustrated in the Android training tutorials by android.com.
Whenever I'm adding the Activity DisplayMessageActivity, I'm getting "Duplicate attribute" as an error. Here's the code:
<application
<activity android.name="DroidStart"/>
<activity
android:name="com.start.droidstart.DisplayMessageActivity"
android:label="#string/title_activity_droid" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Update: I fixed the problems that were pointed out, but I'm still getting the error. Here's my current AndroidMainfest.xml:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.start.droidstart"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="DroidStart"
android:name="com.start.droidstart.DisplayMessageActivity"
android:label="#string/title_activity_droid" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
The error looks like this
Error parsing XML; duplicate attribute. type Android AAPT problem.
My problem was the tools:replace duplicated.
Fixed easy:
tools:replace="android:label,android:theme">
You have at least two errors:
Be sure to close your <application> tag.
Use android:name, not android.name.
So the first 3 lines should change from:
<application
<activity android.name="DroidStart"/>
to
<application>
<activity android:name="DroidStart"/>
Update:
In your updated code, you have:
<activity
android:name="DroidStart"
android:name="com.start.droidstart.DisplayMessageActivity"
You are using android:name twice, which is why you are getting this error. You should probably change this to:
<activity
android:name=".DisplayMessageActivity"
assuming DisplayMessageActivity is the class name of the Activity you which to refer to.
Last, you forgot your manifest end tag: you should have </manifest> at the very end of your file.
change
android.name
into
android:name
on the first line...
For instantapp project also check that you have
xmlns:android = "http://schemas.android.com/apk/res/android"
in app AndroidManifest.xml in manifest tag.
use
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.start.droidstart"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8"
android:targetSdkVersion="15" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/title_activity_droid" >
<activity
android:name=".DisplayMessageActivity"
android:label="#string/title_activity_droid" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".DroidStart"/>
</application>
</manifest>
instead of
<application
<activity android.name="DroidStart"/>
you are using "android.name" instead of "android:name" for declaring activity in manifest and also close first application tag as <application>

app appears in Manage Applications, but not on the main menu

I'm using Eclipse to make an Android app. I've used it before and not had this problem. The console says everything installed ok, so I'm a little confused. I'm not sure what is relevant from logcat, but I can post it if you think that would help.
I've restarted Eclipse, ADB, the emulator, and the Mac several times in various orders and nothing has helped. I know it must be something simple but I haven't played around with this in a few months.
Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.hyser.pinpoint"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="10" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
</application>
<activity android:name=".pinpoint" android:label="pinpoint">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Your Activity needs to be inside of your application tag in your manifest
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity android:name=".pinpoint" android:label="pinpoint">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
It's a similar issue to this:
Unable to start Service Intent
Your <activity> tag needs to be in the <application> block.
Is it possible your manifest does not refer to any activities? If you install an app with no activities in the manifest you will get this behavior.

Categories

Resources