Make a class and paste the function
public String getRotation(Context context){
final int rotation = ((WindowManager) context.getSystemService
(Context.WINDOW_SERVICE)).getDefaultDisplay().getOrientation();
switch (rotation) {
case Surface.ROTATION_0:
return "portrait";
case Surface.ROTATION_90:
return "landscape";
case Surface.ROTATION_180:
return "reverse portrait";
default:
return "reverse landscape";
}
}
This function will return the current phone orientation value string .
No comments:
Post a Comment