Enrique Benitez
Enrique Benitez

Reputation: 679

Android Phonegap screen rotation lock kills my app

i'm having problems with my application, i added an manifest that must prevent screen rotation but when i rotate the screen it kills the app.

Here is my code:

public class avantdroidActivity extends DroidGap {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {       
    super.onCreate(savedInstanceState);
    //setContentView(R.layout.main);
    super.clearCache();        
    super.loadUrl("file:///android_asset/www/redir.html");      
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
}

My AndroidManifest.Xml:

<activity android:name="org.apache.cordova.DroidGap" android:label="@string/app_name" android:configChanges="keyboard|orientation|keyboardHidden"> <intent-filter> </intent-filter> </activity>

What im doing wrong? Thanks!

Upvotes: 1

Views: 4023

Answers (1)

pepyakin
pepyakin

Reputation: 2235

Why are you calling?

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

You can just set your activity orientation in your AndroidManifest. Just add android:screenOrientation="portrait" to your activity tag.

Upvotes: 6

Related Questions