Search code examples
androidopenurl

Android Orientation change by force when using ACTION_VIEW intent


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?


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 );