I have added android:configChanges in Manifest, when I change font size or turn off Wifi, the activity will be restarted automatically. Is there any way I can prevent this restarts ?
Thanks for the help.
<activity android:name="com.example.MainActivity" android:theme="#style/SkoletubeTheme"
android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|screenLayout|fontScale|uiMode|orientation|screenSize|smallestScreenSize"
android:launchMode="singleTask"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
You have already caught the exception. It's happen for android:configChanges . Please remove unnecessary values from android:configChanges. Only keeps orientation .
I think your problem will be solved. Try this and let me know if it's acceptable or not.
Related
So I've seen this asked a few times and usually the answer is that a label hasn't been given to the intent filter. However:
<activity
android:name=".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>
title_activity_main is still being displayed in the launcher rather than app_name.
What small thing am I not seeing here?
Thanks :)
So eventually... After blitzing my ENTIRE environment, reinstalling studio and a new emulator. It worked as documented
EDIT: Also had to blow away the entire SDK
My Titanium Appceleartor(version 3.1.3) app has both portrait & landscape orientations. But in Android device, even when i enabled the "screen rotation" mode, my app renders in both orientation modes. How to prevent the App from rendering in landscape mode when device is "screenLocked"?
My TiApp.xml;
<activity android:alwaysRetainTaskState="true"
android:configChanges="keyboardHidden|Orientation"
android:label="SampleApp" android:name=".SampleAppActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
you need to set protrait orientation to each activity tag
<activity android:alwaysRetainTaskState="true"
android:configChanges="keyboardHidden|Orientation"
android:screenOrientation="portrait"
android:label="SampleApp" android:name=".SampleAppActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
so i would suggest to use custom android manifest.
Copy your AndroidManifest.xml file from build/android folder and put it into the platform/android/ folder of your application. If folders are not present then create them. Now put a android:screenOrientation="portrait" in each activity tag like this:
<activity android:name="YourActivityName"
android:label="YourActName" android:theme="#style/Theme.Titanium"
android:configChanges="keyboardHidden|orientation"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Hi all thanks for the help. I have added these things already in my tiapp.xml. But still problem exists. I figured out that i have set OrientationMode property to all windows in my app, which should not be set because Android takes all 4 orientations by default. We don't need to specify it in code. So i removed this property & now everything works fine..
My app seems to restart when it detects an orientation change. Well not really.
I only have portrait orientation enabled though.
In log cat I can see that my app is still doing calculations, but my progress dialog disappears.
What is going on?
In my manifest file this is my activity.
<activity
android:name=".xxxActivity"
android:label="#string/app_name"
android:configChanges="orientation"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Is there a specific reason why you're listening for the orientation change with android:configChanges="orientation"?
If not, remove that and I suspect your problem will go away.
add this right after the super call
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
Better to change configChanges to
android:configChanges="orientation|keyboardHidden"
I guess, that activity is restarted, because you forgot to add onConfigurationChanged(Configuration) method in your activity.
http://developer.android.com/reference/android/app/Activity.html#onConfigurationChanged(android.content.res.Configuration)
It can be empty but shold be in the activity.
Also android:screenOrientation="portrait" is not needed.
my android application crashes and shows force close when i tilt the mobile phone. is there any suggestions that i can remove such problem? By the way i am developing a LBS application which uses the google maps (MapView).
I have a splash screen and then shown a ListActivity as below :
<activity android:name=".Splash" 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/app_name" android:configChanges="orientation" android:windowSoftInputMode="stateHidden">
<intent-filter>
<action android:name="com.nepways.HOME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
what is wrong with my declaration, the splash screen loads and list activity is also whown correctly but when i change the orientation the application is closed. Please help me.
When you change your orientation the activity is restarted
look at the logcat to see what exception causes your application to FC
You can change your manifest to disable activity restarting by customizing configChanges, if you stil have the problem override onConfigurationChanged() to fix what is generating this exception (like initialize something that may cause a nullpointer)
First of all as it is said the app is restarting (or as it is said in reference redrawing) each time when you change orientation.
To block it in your manifest file in activity you have to put this line which describes the activity orientation:
<activity android:name=".Splash"
android:label="#string/app_name"
android:screenOrientation="portrait">...
And about this buttons, or keymaps. Telling the truth Ive got thise warnings sometimes but it doesnt change anything in my app. So first change the orientation settings and then it should work correct.
If you want use other screen orientation remember to check here:
http://developer.android.com/guide/topics/manifest/activity-element.html
If you want to avoid restarting your activity on orientation change, you can put this in the activity in the manifest file:
android:configChanges="orientation"
Otherwise, we will need to see more code, and a stacktrace.
I want my app to run in the portrait view so I made the following changes in the android manifest file.
android:screenOrientation="portrait"
It stays in the portrait view for a second and then it closes.. I had assumed this is the only change i had to make..but i also added this but it isnt working
android:configChanges="orientation"
Am i missing something?
<activity android:name=".Menu" android:label="COMEDY TRIVIA"
android:screenOrientation="portrait" android:configChanges="orientation"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen">
<intent-filter>
<action android:name="nik.trivia.MENU" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
Try this adding android:configChanges to your AndroidManifest file in the activity tag
<activity android:name=".Fourth" android:label="Fourth" android:configChanges="orientation|keyboardHidden"></activity>
Hope this works for you.