Question

I have Application which is landscape mode.

I put attribute " android:screenOrientation="landscape" " in manifest file.

My application has following code.

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("tstore://someAppsId"));
activity.startActivity(intent);

There is generally used T-store application for android in Korea. T-store application deal url schema "tstore://".

My code is just opening T-store app.

Unfortunately, T-store application only support portrait.

There is problem.

Just before open t-store activity, android OS change orientation of my activity to portrait mode in a moment(0.2 sec?) then open t-store activity.

This doesn't happen Android Market App which support landscape mode.

Is there way to strongly prevent orientation change in this case?

Was it helpful?

Solution

Just set the orientation of your activity from the code, in this way it will be much easier to control the orientation according to your requirements. The code for setting the orientation is, for portrait orientation

     setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT );

and for landscape orientation,

     setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE );

OTHER TIPS

in your aactivity add below code.

for portrait

@override
protected void onResume(){
 setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT );
}

for landscape

@override
protected void onResume(){
 setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE );
}

Try adding android:configChanges="orientation" attribute to the manifest file.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top