Search code examples
androidcordovascreen-rotation

Android phone rotation issues in phoneGap native app


I'm quite new in Java android development. So I have an issue with my app.

I was build a android app with phoneGap opensource and Jquery mobile framework. That's looking good normally working.

But the issue is.... when I'm trying to rotate the phone after running the app, then unexpectedly the app is closing.

It's not only for my phone it's happening on every android phone.

I really want to remove the screen rotation on the app.

Hope you understand

Help me please....


Solution

  • I had probably the same issue - crash on rotate. I dont think I had the AndroidManifest.xml copied right from the tutorial. I didnt add

     android:configChanges="orientation|keyboardHidden" 
    

    to the 1st activity. See my after and before:

    After (working):

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:name=".App"
            android:label="@string/app_name"  android:configChanges="orientation|keyboardHidden">
            <intent-filter>
    

    Before (crash on rotate):

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:name=".App"
            android:label="@string/app_name">
            <intent-filter>
    

    Not sure if you really want to fix the screen or stop it crashing but if you want to fix portrait or landscape you can do this:

        <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:name=".App"
            android:label="@string/app_name"  android:configChanges="orientation|keyboardHidden"
            android:screenOrientation="landscape" >
            <intent-filter>