當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。