I need to disable splash screen auto rotate.
Need to show splash screen in portrait mode only. But app must rotate with auto rotate. How to do it in android studio ?
Add in Manifest file-->
<application
.........
>
<activity
android:name=".SplashScreenActivity"
......
android:screenOrientation="portrait"
/>
</application>
or for horizontal mode
<activity
...
...
android:screenOrientation="landscape">
In Your AndroidMainfest.xml put the screen orientation to your splash
<activity
android:name=".SplashScreenActivity"
android:label="#string/app_name"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
In the manifest, set this for your splash screen activity:
<activity android:name=".YourActivity"
android:configChanges="orientation"
android:screenOrientation="portrait"/>
In manifest you can set the specific activity to be in portrait mode using
android:screenOrientation="portrait"
Just add below line in your manifest file, in splash activity tag
android:screenOrientation="portrait"
Something like below
<activity
android:name=".SplashActivity"
android:screenOrientation="portrait" >
Add to your splash activity declaration in the manifest this lines:
<activity
android:name="SplashActivity"
android:screenOrientation="portrait"
android:configChanges="keyboardHidden|orientation|screenSize">
Find relevant discussion here.
You Can do it by couple of ways
One
Inside the onCreate method of your activity
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
Two
In manifest file
<activity
android:name=".NameOfYourSplashScreenActivity"
android:label="#string/app_name"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Hope it helps
Add following code to your splash screen activity declaration in Manifest
<activity android:name=".YourActivityName"
android:label="#string/app_name"
android:configChanges = "orientation"
android:screenOrientation = "portrait">
or else add
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
to YourActivity.onCreate()
you can find a sample demo file here in github
try this in manifiest
<activity
android:name=".SplashScreenActivity"
android:label="#string/app_name"
android:screenOrientation="portrait"/>
Related
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>
I am facing an issue that ,When ever I start the app and press home button ,then again I click the apps icon a new instance of that app is created . How to solve this issue ?
My Manifest file as follows ,
<activity
android:name="com.example.mytast.MainActivity"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:configChanges="orientation|keyboardHidden"
android:alwaysRetainTaskState="True"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Add:
<activity
android:name="com.example.mytast.MainActivity"
android:launchMode="singleTask"
...
>
</activity>
and remove:
android:alwaysRetainTaskState="true"
from the directive.
I had an app with several activities running perfectly until I added a new activity, which became the launch activity.
Now, the app stars in that activity but when I go to another activity it says Activity Not Found Exception even the activities are declared.
Here is my manifest, as I do not know what I am missing.
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.visualizacion.Menu"
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.example.cuestionario.Page1"
android:configChanges="orientation"
android:screenOrientation="sensorLandscape"></activity>
<activity android:name=".com.example.cuestionario.Page3"
android:configChanges="orientation"
android:screenOrientation="sensorLandscape"></activity>
<activity android:name="com.example.cuestionario.Page2"
android:configChanges="orientation"
android:screenOrientation="sensorLandscape" ></activity>
<activity android:name="com.example.cuestionario.Page4"
android:configChanges="orientation"
android:screenOrientation="sensorLandscape" ></activity>
<activity android:name="com.example.cuestionario.Page5"
android:configChanges="orientation"
android:screenOrientation="sensorLandscape" ></activity>
<activity android:name="com.example.cuestionario.Page6"
android:configChanges="orientation"
android:screenOrientation="sensorLandscape" ></activity>
<activity android:name="com.example.cuestionario.Page7"
android:configChanges="orientation"
android:screenOrientation="sensorLandscape" ></activity>
<activity android:name="com.example.visualizacion.Page1C"
android:configChanges="orientation"
android:screenOrientation="sensorLandscape" ></activity>
<activity android:name="com.example.visualiacion.Page2C"
android:configChanges="orientation"
android:screenOrientation="sensorLandscape" ></activity>
</application>
When I go from Menu (Launcher Activity) to another activity it crashes with that exception.
Thank you
Check package path of your classes declared in Android Manifest and remove .(dot) from full class name. for Page1 and Page 3. i.e
android:name=".com.example.cuestionario.Page1"
and
android:name=".com.example.cuestionario.Page3"
I want to keep landscape mode always.
I Lock screen to portrait mode on Nexus7, I set android:screenOrientation="sensorLandscape" and android:configChanges="orientation|keyboardHidden"in AndroidManifest.xml, when I go to other activity and back to this activity, then the screen will rotate portrait and rotate to landscape again (Didn't call onCreate method again), but I don't want to rotate the screen in any situations, how to fix it?
I think this is the answere you're looking for:
stackoverflow.com/a/2730894/2249774
For All your Activities in the manifest set
android:screenOrientation="sensorLandscape" android:configChanges="orientation|keyboardHidden"
Example :-
<activity android:name="com.example.test.testActivity" android:label="#string/app_name" android:screenOrientation="sensorLandscape" android:configChanges="orientation|keyboardHidden"">
<intent-filter>
<action android:name="com.example.test.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
Repeat this for all activities used in the manifest..
Try editing your AndroidManifest.xml to look like this
<activity
android:name=".YOURACTIVITYNAME"
android:screenOrientation="landscape" />
In your AndroidManifest file, try typing in the following code:
android:configChanges="keyboard|orientation|keyboardHidden|screenSize"
android:screenOrientation="landscape"
example:
<activity
android:name="com.gaspar.slinfilipino.Quiz"
android:label="#string/title_activity_quiz"
android:configChanges="keyboard|orientation|keyboardHidden|screenSize"
android:screenOrientation="landscape"
android:parentActivityName="com.gaspar.slinfilipino.SignLanguageMenu" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.gaspar.slinfilipino.SignLanguageMenu" />
</activity>
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.