当前位置: 首页>>代码示例>>Java>>正文


Java UiModeManager.getCurrentModeType方法代码示例

本文整理汇总了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 "";
    }
}
 
开发者ID:kranthi0987,项目名称:easyfilemanager,代码行数:24,代码来源:Utils.java

示例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();
}
 
开发者ID:mrinalgit-dev,项目名称:MrinalMusicPlayer,代码行数:17,代码来源:NowPlayingActivity.java

示例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();
}
 
开发者ID:SoumyaParida,项目名称:MyGaana-Universal,代码行数:19,代码来源:NowPlayingActivity.java

示例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);
    }
}
 
开发者ID:moonlight-stream,项目名称:moonlight-android,代码行数:17,代码来源:UiHelper.java

示例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;
}
 
开发者ID:NeoTerm,项目名称:NeoTerm,代码行数:10,代码来源:MainActivity.java

示例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;
    }
}
 
开发者ID:pe-pan,项目名称:flappy,代码行数:9,代码来源:TlappyActivity.java

示例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;
    }
}
 
开发者ID:lifechurch,项目名称:nuclei-android,代码行数:21,代码来源:CarHelper.java

示例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;
}
 
开发者ID:ayaseruri,项目名称:luxunPro,代码行数:16,代码来源:DeviceUtil.java

示例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 {}
}
 
开发者ID:ChiangC,项目名称:FMTech,代码行数:30,代码来源:UiUtils.java

示例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;
    }
}
 
开发者ID:googlesamples,项目名称:android-UniversalMusicPlayer,代码行数:17,代码来源:TvHelper.java

示例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;
}
 
开发者ID:google,项目名称:talkback,代码行数:11,代码来源:TelevisionNavigationController.java

示例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;
    }
}
 
开发者ID:jhmgbl,项目名称:learnforandroidfragAS,代码行数:13,代码来源:lib.java

示例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;
    }
}
 
开发者ID:GeorgeMe,项目名称:UniversalAndroidMusicPlayer,代码行数:17,代码来源:CarHelper.java

示例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();
}
 
开发者ID:AdaptiveMe,项目名称:adaptive-arp-android,代码行数:11,代码来源:CapabilitiesDelegate.java

示例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;
}
 
开发者ID:oakesville,项目名称:mythling,代码行数:8,代码来源:AppSettings.java


注:本文中的android.app.UiModeManager.getCurrentModeType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。