Reputation: 1969
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);
}
}
});
}
Upvotes: 8
Views: 1127
Reputation: 1969
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.
Upvotes: 1