Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SCREEN_ORIENTATION_REVERSE_PORTRAIT is correct?

Well I'm trying to add a lock orientation button, but when I call

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT);

the screen goes to normal portrait. What am I doing wrong?

public void onSensorChanged(SensorEvent event) {

    x = event.values[0];
    y = event.values[1];
    z = event.values[2];

    orientation.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            // TODO Auto-generated method stub
            if (x > 5){
                setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
            } else if (x < -5){
                setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
            } else if (y > 5){
                setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
            } else if (y < -5){
                setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT);
            }
        }
    });
}
like image 873
Rotary Heart Avatar asked Nov 01 '12 13:11

Rotary Heart


1 Answers

Well I solved it changing

android:targetSdkVersion="15"

to this

android:targetSdkVersion="11"

in the manifest, I don't really think that this was the problem, but now its working. Just wanted to post it in case anyone have the issue.

like image 190
Rotary Heart Avatar answered Nov 14 '22 22:11

Rotary Heart