Display rotation android [Solved]

Hi everyone, i have some rooms that the player will play on landscape mode and other on protrait mode,
but i dont want the player to be able to change to portrait or landscape by himself, so the the orientation is locked, basically i want to change the orientation myself by code and have it locked to the player.
I tried with camera and views but i cant get it to work correctly. Thank!
 
well i find a solution if anyone needs this too:

You have to create an extension and put these
Code:
package ${YYAndroidPackageName};

import android.util.Log;
import java.io.File;
import java.io.FileReader;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.lang.String;

import android.content.pm.ActivityInfo;
import android.support.v7.app.AppCompatActivity;

import ${YYAndroidPackageName}.R;
import com.yoyogames.runner.RunnerJNILib;
import ${YYAndroidPackageName}.RunnerActivity;


public class JavaTest extends AppCompatActivity
{

    public double TurnPortrait()
    {
        RunnerActivity.CurrentActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        return 1;
    }

    public double TurnLandscape()
    {
        RunnerActivity.CurrentActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        return 1;
    }

}
and put these for the graddle part in the extension

Code:
compile 'com.android.support:appcompat-v7:${YYAndroidSupportLibVersion}'
so basically you call TurnPortrait() and TurnLandscape() when u need.

remember that it returns 1, so you have to put that it returns double for both functions
 
Top