本文整理汇总了Java中android.content.pm.ActivityInfo.ScreenOrientation方法的典型用法代码示例。如果您正苦于以下问题:Java ActivityInfo.ScreenOrientation方法的具体用法?Java ActivityInfo.ScreenOrientation怎么用?Java ActivityInfo.ScreenOrientation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.content.pm.ActivityInfo
的用法示例。
在下文中一共展示了ActivityInfo.ScreenOrientation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRequestedOrientation
import android.content.pm.ActivityInfo; //导入方法依赖的package包/类
/**
* Return the current requested orientation of the activity. This will
* either be the orientation requested in its component's manifest, or
* the last requested orientation given to
* {@link #setRequestedOrientation(int)}.
*
* @return Returns an orientation constant as used in
* {@link ActivityInfo#screenOrientation ActivityInfo.screenOrientation}.
*/
@ActivityInfo.ScreenOrientation
public int getRequestedOrientation() {
if (mParent == null) {
try {
return ActivityManagerNative.getDefault()
.getRequestedOrientation(mToken);
} catch (RemoteException e) {
// Empty
}
} else {
return mParent.getRequestedOrientation();
}
return ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
}
示例2: setRequestedOrientation
import android.content.pm.ActivityInfo; //导入方法依赖的package包/类
/**
* Change the desired orientation of this activity. If the activity
* is currently in the foreground or otherwise impacting the screen
* orientation, the screen will immediately be changed (possibly causing
* the activity to be restarted). Otherwise, this will be used the next
* time the activity is visible.
*
* @param requestedOrientation An orientation constant as used in
* {@link ActivityInfo#screenOrientation ActivityInfo.screenOrientation}.
*/
public void setRequestedOrientation(@ActivityInfo.ScreenOrientation int requestedOrientation) {
if (mParent == null) {
try {
ActivityManagerNative.getDefault().setRequestedOrientation(
mToken, requestedOrientation);
} catch (RemoteException e) {
// Empty
}
} else {
mParent.setRequestedOrientation(requestedOrientation);
}
}