本文整理汇总了Java中android.app.UiModeManager.getCurrentModeType方法的典型用法代码示例。如果您正苦于以下问题:Java UiModeManager.getCurrentModeType方法的具体用法?Java UiModeManager.getCurrentModeType怎么用?Java UiModeManager.getCurrentModeType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.app.UiModeManager
的用法示例。
在下文中一共展示了UiModeManager.getCurrentModeType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDeviceType
import android.app.UiModeManager; //导入方法依赖的package包/类
/**
* Returns true when running Android TV
*
* @param c Context to detect UI Mode.
* @return true when device is running in tv mode, false otherwise.
*/
public static String getDeviceType(Context c) {
UiModeManager uiModeManager = (UiModeManager) c.getSystemService(Context.UI_MODE_SERVICE);
int modeType = uiModeManager.getCurrentModeType();
switch (modeType){
case Configuration.UI_MODE_TYPE_TELEVISION:
return "TELEVISION";
case Configuration.UI_MODE_TYPE_WATCH:
return "WATCH";
case Configuration.UI_MODE_TYPE_NORMAL:
String type = isTablet(c) ? "TABLET" : "PHONE";
return type;
case Configuration.UI_MODE_TYPE_UNDEFINED:
return "UNKOWN";
default:
return "";
}
}
示例2: onCreate
import android.app.UiModeManager; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
LogHelper.d(TAG, "onCreate");
Intent newIntent;
UiModeManager uiModeManager = (UiModeManager) getSystemService(UI_MODE_SERVICE);
if (uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION) {
LogHelper.d(TAG, "Running on a TV Device");
newIntent = new Intent(this, TvPlaybackActivity.class);
} else {
LogHelper.d(TAG, "Running on a non-TV Device");
newIntent = new Intent(this, MusicPlayerActivity.class);
}
startActivity(newIntent);
finish();
}
示例3: onCreate
import android.app.UiModeManager; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.d(TAG, "onCreate");
Intent newIntent;
UiModeManager uiModeManager = (UiModeManager) getSystemService(UI_MODE_SERVICE);
if (uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION) {
Log.d(TAG, "Running on a TV Device");
// TODO: add launch Android TV "Now Playing" activity
// newIntent = new Intent(this, TvNowPlayingActivity.class);
throw new UnsupportedOperationException("Android TV is not yet supported");
} else {
Log.d(TAG, "Running on a non-TV Device");
newIntent = new Intent(this, MusicPlayerActivity.class);
}
startActivity(newIntent);
finish();
}
示例4: notifyNewRootView
import android.app.UiModeManager; //导入方法依赖的package包/类
public static void notifyNewRootView(Activity activity)
{
View rootView = activity.findViewById(android.R.id.content);
UiModeManager modeMgr = (UiModeManager) activity.getSystemService(Context.UI_MODE_SERVICE);
if (modeMgr.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION)
{
// Increase view padding on TVs
float scale = activity.getResources().getDisplayMetrics().density;
int verticalPaddingPixels = (int) (TV_VERTICAL_PADDING_DP*scale + 0.5f);
int horizontalPaddingPixels = (int) (TV_HORIZONTAL_PADDING_DP*scale + 0.5f);
rootView.setPadding(horizontalPaddingPixels, verticalPaddingPixels,
horizontalPaddingPixels, verticalPaddingPixels);
}
}
示例5: isRunningOnOUYA
import android.app.UiModeManager; //导入方法依赖的package包/类
public boolean isRunningOnOUYA() {
try {
PackageInfo packageInfo = getPackageManager().getPackageInfo("tv.ouya", 0);
return true;
} catch (PackageManager.NameNotFoundException e) {
}
UiModeManager uiModeManager = (UiModeManager) getSystemService(UI_MODE_SERVICE);
return (uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION) || Globals.OuyaEmulation;
}
示例6: isAndroidTV
import android.app.UiModeManager; //导入方法依赖的package包/类
public boolean isAndroidTV() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
UiModeManager uiModeManager = (UiModeManager) getSystemService(UI_MODE_SERVICE);
return uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION;
} else {
return false;
}
}
示例7: isCarUiMode
import android.app.UiModeManager; //导入方法依赖的package包/类
/**
* Returns true when running Android Auto or a car dock.
*
* A preferable way of detecting if your app is running in the context of an Android Auto
* compatible car is by registering a BroadcastReceiver for the action
* {@link CarHelper#ACTION_MEDIA_STATUS}.
*
* @param c Context to detect UI Mode.
* @return true when device is running in car mode, false otherwise.
*/
public static boolean isCarUiMode(Context c) {
UiModeManager uiModeManager = (UiModeManager) c.getSystemService(Context.UI_MODE_SERVICE);
if (uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_CAR) {
LOG.d("Running in Car mode");
return true;
} else {
LOG.d("Running on a non-Car mode");
return false;
}
}
示例8: isDeviceTV
import android.app.UiModeManager; //导入方法依赖的package包/类
/**
* Determines if the current device is a TV.
*
* @param context The context to use for determining the device information
* @return True if the current device is a TV
*/
public boolean isDeviceTV(Context context) {
//Since Android TV is only API 21+ that is the only time we will compare configurations
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
UiModeManager uiManager = (UiModeManager) context.getSystemService(Context.UI_MODE_SERVICE);
return uiManager != null && uiManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION;
}
return false;
}
示例9: isAndroidTv
import android.app.UiModeManager; //导入方法依赖的package包/类
public static boolean isAndroidTv()
{
try
{
if (sIsAndroidTv == null)
{
FinskyApp localFinskyApp = FinskyApp.get();
boolean bool2 = localFinskyApp.getPackageManager().hasSystemFeature("android.software.leanback");
boolean bool3 = false;
if (bool2)
{
UiModeManager localUiModeManager = (UiModeManager)localFinskyApp.getSystemService("uimode");
bool3 = false;
if (localUiModeManager != null)
{
int i = localUiModeManager.getCurrentModeType();
bool3 = false;
if (i == 4) {
bool3 = true;
}
}
}
sIsAndroidTv = Boolean.valueOf(bool3);
}
boolean bool1 = sIsAndroidTv.booleanValue();
return bool1;
}
finally {}
}
示例10: isTvUiMode
import android.app.UiModeManager; //导入方法依赖的package包/类
/**
* Returns true when running Android TV
*
* @param c Context to detect UI Mode.
* @return true when device is running in tv mode, false otherwise.
*/
public static boolean isTvUiMode(Context c) {
UiModeManager uiModeManager = (UiModeManager) c.getSystemService(Context.UI_MODE_SERVICE);
if (uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION) {
LogHelper.d(TAG, "Running in TV mode");
return true;
} else {
LogHelper.d(TAG, "Running on a non-TV mode");
return false;
}
}
示例11: isContextTelevision
import android.app.UiModeManager; //导入方法依赖的package包/类
public static boolean isContextTelevision(Context context) {
if (context == null) {
return false;
}
UiModeManager modeManager =
(UiModeManager) context.getSystemService(Context.UI_MODE_SERVICE);
return modeManager != null &&
modeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION;
}
示例12: getUIMode
import android.app.UiModeManager; //导入方法依赖的package包/类
public static int getUIMode(Context context)
{
if (Build.VERSION.SDK_INT >= 8)
{
UiModeManager uiModeManager = (UiModeManager) context.getSystemService(Context.UI_MODE_SERVICE);
return uiModeManager.getCurrentModeType();
}
else
{
return 0;
}
}
示例13: isCarUiMode
import android.app.UiModeManager; //导入方法依赖的package包/类
/**
* Returns true when running Android Auto or a car dock.
*
* @param c Context to detect UI Mode.
* @return true when device is running in car mode, false otherwise.
*/
public static boolean isCarUiMode(Context c) {
UiModeManager uiModeManager = (UiModeManager) c.getSystemService(Context.UI_MODE_SERVICE);
if (uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_CAR) {
LogHelper.d(TAG, "Running in Car mode");
return true;
} else {
LogHelper.d(TAG, "Running on a non-Car mode");
return false;
}
}
示例14: CapabilitiesDelegate
import android.app.UiModeManager; //导入方法依赖的package包/类
/**
* Default Constructor.
*/
public CapabilitiesDelegate() {
super();
Context context = (Context) AppRegistryBridge.getInstance().getPlatformContext().getContext();
UiModeManager uiModeManager = (UiModeManager) context.getSystemService(context.UI_MODE_SERVICE);
tv = uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION;
pm = context.getPackageManager();
}
示例15: isTv
import android.app.UiModeManager; //导入方法依赖的package包/类
public boolean isTv() {
if (isTv == null) {
UiModeManager modeMgr = (UiModeManager)appContext.getSystemService(Context.UI_MODE_SERVICE);
isTv = modeMgr.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION;
}
return isTv;
}