Force Phonegap (Android) screen saver screen

I added a splash screen to my phone app by adding "super.setIntegerProperty" ("splashscreen", R.drawable.splash); to the line super.loadURL ... in DefaultActivity.

Is there a way to block only the orientation of the splash screen on a portrait without locking the entire application?

+5
source share
5 answers

If you are using the latest version of PhoneGap (DroidGap) or Apache Cordova, you can force the screen orientation to landscape by changing the screen orientation in the Android.xml file. The resulting DroidGap instance creation activity should look something like this:

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

Cordova 3+ Android iOS. , , .

config.xml:

<preference name="orientation" value="portrait" />

, :

document.addEventListener("deviceready", function(){
    screen.unlockOrientation();
}, false);
+5

After many searches, I found that the correct way to orient the screensaver orientation is to manage two images using this code inMainActivity

 if (getResources().getConfiguration().orientation == 2) {
        super.setIntegerProperty("splashscreen", R.drawable.splashlandscape);
        Log.d("Orientation", "Landscape");
    }
    else {
        super.setIntegerProperty("splashscreen", R.drawable.splashportrait);
        Log.d("Orientation", "Portrait");
    }
+4
source

Write the following inside the onCreate method of the splashscreen activity:

setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

0
source

Add this line to your AndroidManifest.xml:

<activity android:name="SplashScreen" android:screenOrientation="portrait"></activity> 
0
source

All Articles