Example usage for android.content.res Configuration UI_MODE_TYPE_TELEVISION

List of usage examples for android.content.res Configuration UI_MODE_TYPE_TELEVISION

Introduction

In this page you can find the example usage for android.content.res Configuration UI_MODE_TYPE_TELEVISION.

Prototype

int UI_MODE_TYPE_TELEVISION

To view the source code for android.content.res Configuration UI_MODE_TYPE_TELEVISION.

Click Source Link

Document

Constant for #uiMode : a #UI_MODE_TYPE_MASK value that corresponds to the television resource qualifier.

Usage

From source file:Main.java

public static boolean isTV(Context context) {
    UiModeManager uiModeManager = (UiModeManager) context.getSystemService(Context.UI_MODE_SERVICE);
    return uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION;
}

From source file:Main.java

public static boolean isTv(Context context) {

    final UiModeManager manager = (UiModeManager) context.getSystemService(Context.UI_MODE_SERVICE);

    return manager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION;
}

From source file:org.uoyabause.android.Notification.java

public void showVersionUpNOtification(RemoteMessage remoteMessage) {

    //https://play.google.com/store/apps/details?id=org.uoyabause.android

    Intent googlePlayIntent = new Intent(Intent.ACTION_VIEW);
    googlePlayIntent.setData(Uri.parse("market://details?id=org.uoyabause.android"));
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, googlePlayIntent,
            PendingIntent.FLAG_ONE_SHOT);

    Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this).setSmallIcon(R.drawable.icon)
            .setContentTitle("new uoYabause is available")
            .setContentText(remoteMessage.getNotification().getBody()).setSound(defaultSoundUri)
            .setContentIntent(pendingIntent).setAutoCancel(false)
            //.setPriority(android.app.Notification.PRIORITY_MAX)
            .addAction(android.R.drawable.ic_media_play, "Install", pendingIntent);
    android.app.Notification notification = null;
    UiModeManager uiModeManager = (UiModeManager) getSystemService(UI_MODE_SERVICE);
    if (uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION) {
        Resources r = getResources();
        Bitmap image = BitmapFactory.decodeResource(r, R.drawable.banner);
        mBuilder.setCategory(android.app.Notification.CATEGORY_RECOMMENDATION).setLargeIcon(image)
                .setLocalOnly(true).setOngoing(true);
        notification = new NotificationCompat.BigPictureStyle(mBuilder).build();
    } else {/*ww  w  . j ava2 s . co m*/
        notification = mBuilder.build();
    }

    NotificationManager notificationManager = (NotificationManager) getSystemService(
            Context.NOTIFICATION_SERVICE);

    notificationManager.notify(0 /* ID of notification */, notification);
}

From source file:com.grarak.kerneladiutor.utils.Utils.java

public static boolean isTv(Context context) {
    return ((UiModeManager) context.getSystemService(Context.UI_MODE_SERVICE))
            .getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION;
}

From source file:org.uoyabause.android.Notification.java

@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
    super.onMessageReceived(remoteMessage);

    Log.d(TAG, "From: " + remoteMessage.getFrom());
    Log.d(TAG, "Notification Message Body: " + remoteMessage.getNotification().getBody());

    Map<String, String> val = remoteMessage.getData();

    PackageManager pm = this.getPackageManager();
    String sentversion = null;/* w w w .j a  va 2  s .c  om*/
    int CurrentVersion = -1;
    try {
        PackageInfo packageInfo = pm.getPackageInfo(this.getPackageName(), 0);
        CurrentVersion = packageInfo.versionCode;
    } catch (Exception e) {

    }
    sentversion = val.get("version");

    // Version up Information
    if (sentversion != null) {

        if (Integer.parseInt(sentversion) != CurrentVersion) {
            showVersionUpNOtification(remoteMessage);
        }
        return;
    }

    Intent intent = new Intent(this, GameSelectActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent,
            PendingIntent.FLAG_ONE_SHOT);

    Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this).setSmallIcon(R.drawable.icon)
            .setContentTitle("uoYabause").setContentText(remoteMessage.getNotification().getBody())
            .setAutoCancel(true).setSound(defaultSoundUri).setContentIntent(pendingIntent);
    android.app.Notification notification = null;
    UiModeManager uiModeManager = (UiModeManager) getSystemService(UI_MODE_SERVICE);
    if (uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION) {
        Resources r = getResources();
        Bitmap image = BitmapFactory.decodeResource(r, R.drawable.banner);
        mBuilder.setCategory("recommendation").setLargeIcon(image).setLocalOnly(true)
                .setCategory(android.app.Notification.CATEGORY_RECOMMENDATION).setOngoing(true);
        notification = new NotificationCompat.BigPictureStyle(mBuilder).build();
    } else {
        notification = mBuilder.build();
    }

    NotificationManager notificationManager = (NotificationManager) getSystemService(
            Context.NOTIFICATION_SERVICE);

    notificationManager.notify(0 /* ID of notification */, notification);

}

From source file:github.daneren2005.dsub.activity.SubsonicActivity.java

@Override
protected void onCreate(Bundle bundle) {
    UiModeManager uiModeManager = (UiModeManager) getSystemService(UI_MODE_SERVICE);
    if (uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION) {
        // tv = true;
    }//from   www  .  j a v  a2 s .c o  m
    PackageManager pm = getPackageManager();
    if (!pm.hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN)) {
        touchscreen = false;
    }

    setUncaughtExceptionHandler();
    applyTheme();
    applyFullscreen();
    super.onCreate(bundle);
    startService(new Intent(this, DownloadService.class));
    setVolumeControlStream(AudioManager.STREAM_MUSIC);

    if (getIntent().hasExtra(Constants.FRAGMENT_POSITION)) {
        lastSelectedPosition = getIntent().getIntExtra(Constants.FRAGMENT_POSITION, 0);
    }

    if (preferencesListener == null) {
        preferencesListener = new SharedPreferences.OnSharedPreferenceChangeListener() {
            @Override
            public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
                // When changing drawer settings change visibility
                switch (key) {
                case Constants.PREFERENCES_KEY_PODCASTS_ENABLED:
                    setDrawerItemVisible(R.id.drawer_podcasts, false);
                    break;
                case Constants.PREFERENCES_KEY_BOOKMARKS_ENABLED:
                    setDrawerItemVisible(R.id.drawer_bookmarks, false);
                    break;
                case Constants.PREFERENCES_KEY_SHARED_ENABLED:
                    setDrawerItemVisible(R.id.drawer_shares, false);
                    break;
                case Constants.PREFERENCES_KEY_CHAT_ENABLED:
                    setDrawerItemVisible(R.id.drawer_chat, false);
                    break;
                case Constants.PREFERENCES_KEY_ADMIN_ENABLED:
                    setDrawerItemVisible(R.id.drawer_admin, false);
                    break;
                }
            }
        };
        Util.getPreferences(this).registerOnSharedPreferenceChangeListener(preferencesListener);
    }
}

From source file:com.google.android.apps.santatracker.games.SplashActivity.java

private boolean isRunningOnTV() {
    UiModeManager uiModeManager = (UiModeManager) getSystemService(UI_MODE_SERVICE);
    return uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION;
}

From source file:github.popeen.dsub.activity.SubsonicActivity.java

@Override
protected void onCreate(Bundle bundle) {

    sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
    sensorManager.registerListener(this, sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER),
            SensorManager.SENSOR_DELAY_NORMAL);

    UiModeManager uiModeManager = (UiModeManager) getSystemService(UI_MODE_SERVICE);
    if (uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION) {
        // tv = true;
    }//from w  w w .j  a  v  a2 s  . c o m
    PackageManager pm = getPackageManager();
    if (!pm.hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN)) {
        touchscreen = false;
    }

    setUncaughtExceptionHandler();
    applyTheme();
    applyFullscreen();
    super.onCreate(bundle);
    startService(new Intent(this, DownloadService.class));
    setVolumeControlStream(AudioManager.STREAM_MUSIC);

    if (getIntent().hasExtra(Constants.FRAGMENT_POSITION)) {
        lastSelectedPosition = getIntent().getIntExtra(Constants.FRAGMENT_POSITION, 0);
    }

    if (preferencesListener == null) {
        preferencesListener = new SharedPreferences.OnSharedPreferenceChangeListener() {
            @Override
            public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
                // When changing drawer settings change visibility
                switch (key) {
                case Constants.PREFERENCES_KEY_PODCASTS_ENABLED:
                    setDrawerItemVisible(R.id.drawer_podcasts, false);
                    break;
                case Constants.PREFERENCES_KEY_BOOKMARKS_ENABLED:
                    setDrawerItemVisible(R.id.drawer_bookmarks, false);
                    break;
                case Constants.PREFERENCES_KEY_INTERNET_RADIO_ENABLED:
                    setDrawerItemVisible(R.id.drawer_internet_radio_stations, false);
                    break;
                case Constants.PREFERENCES_KEY_SHARED_ENABLED:
                    setDrawerItemVisible(R.id.drawer_shares, false);
                    break;
                case Constants.PREFERENCES_KEY_CHAT_ENABLED:
                    setDrawerItemVisible(R.id.drawer_chat, false);
                    break;
                case Constants.PREFERENCES_KEY_ADMIN_ENABLED:
                    setDrawerItemVisible(R.id.drawer_admin, false);
                    break;
                }
            }
        };
        Util.getPreferences(this).registerOnSharedPreferenceChangeListener(preferencesListener);
    }

    if (ContextCompat.checkSelfPermission(this,
            permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
        ActivityCompat.requestPermissions(this, new String[] { permission.WRITE_EXTERNAL_STORAGE },
                PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE);
    }
}

From source file:com.greatnowhere.radar.MainRadarActivity.java

private String getCurrentUIModeString(int mode) {
    switch (mode) {
    case Configuration.UI_MODE_TYPE_APPLIANCE:
        return "Appliance";
    case Configuration.UI_MODE_TYPE_CAR:
        return "Car";
    case Configuration.UI_MODE_TYPE_DESK:
        return "Desk";
    case Configuration.UI_MODE_TYPE_TELEVISION:
        return "TV";
    case Configuration.UI_MODE_TYPE_NORMAL:
        return "Normal";
    }//from www  . j a va 2 s . com
    return "Unknown";
}

From source file:org.de.jmg.learn.MainActivity.java

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    blnTextToSpeech = false;//  www .  j a  v  a2s.c  o  m
    lib.main = this;

    //getting the kind of userinterface: television or watch or else
    int UIMode = lib.getUIMode(this);
    switch (UIMode) {
    case Configuration.UI_MODE_TYPE_TELEVISION:
        isTV = true;
        break;
    case Configuration.UI_MODE_TYPE_WATCH:
        isWatch = true;
        break;
    }

    if (savedInstanceState != null) {
        JMGDataDirectory = savedInstanceState.getString("JMGDataDirectory");
    }

    setContentView(R.layout.activity_main_viewpager);

    /** Getting a reference to ViewPager from the layout */
    View pager = this.findViewById(R.id.pager);
    Layout = (ViewGroup) pager;
    mPager = (ViewPager) pager;

    /** Getting a reference to FragmentManager */
    FragmentManager fm = getSupportFragmentManager();

    setPageChangedListener();

    /** Creating an instance of FragmentPagerAdapter */
    if (fPA == null) {
        fPA = new MyFragmentPagerAdapter(fm, this, savedInstanceState != null);
    }

    /** Setting the FragmentPagerAdapter object to the viewPager object */
    mPager.setAdapter(fPA);
    //mPager.setCurrentItem(0);

    libLearn.gStatus = "onCreate getEink";
    try {
        _blnEink = getWindowManager().getDefaultDisplay().getRefreshRate() < 5.0;
        if (_blnEink)
            lib.ShowToast(this, "This is an Eink diplay!");
    } catch (Exception ex) {
        lib.ShowException(this, ex);
    }

    try {
        libLearn.gStatus = "onCreate setContentView";
        mainView = findViewById(Window.ID_ANDROID_CONTENT);
        defaultErrorHandler = Thread.getDefaultUncaughtExceptionHandler();
        Thread.setDefaultUncaughtExceptionHandler(ErrorHandler);

        // View LayoutMain = findViewById(R.id.layoutMain);

        processPreferences(savedInstanceState != null);

        libLearn.gStatus = "onCreate Copy Assets";
        CopyAssets();

        try {
            processBundle(savedInstanceState);
        } catch (Exception e) {

            e.printStackTrace();
            lib.ShowException(this, e);
        }
        //InitSettings();
        Intent intent = getIntent();
        if (Intent.ACTION_VIEW.equals(intent.getAction())) {
            Uri uri = intent.getData();
            if (uri.toString().startsWith("loginquizlet:/")) {
                loginQuizlet = new LoginQuizletActivity();
                this.onNewIntent(intent);
            }

            //finish();
        }

    } catch (Exception ex) {
        lib.ShowException(this, ex);
    }

}