List of usage examples for android.media.tv TvContract buildInputId
public static String buildInputId(ComponentName name)
From source file:Main.java
public static String getInputId() { ComponentName componentName = new ComponentName("ie.macinnes.tvheadend", ".tvinput.TvInputService"); return TvContract.buildInputId(componentName); }
From source file:com.android.usbtuner.setup.TunerSetupActivity.java
/** * Returns a {@link Intent} to launch the USB tuner TV input service. * * @param context a {@link Context} instance *//*from w w w .j ava 2s . c o m*/ public static Intent createSetupActivity(Context context) { String inputId = TvContract .buildInputId(new ComponentName(context.getPackageName(), UsbTunerTvInputService.class.getName())); // Make an intent to launch the setup activity of USB tuner TV input. Intent intent = TvCommonUtils.createSetupIntent(new Intent(context, TunerSetupActivity.class), inputId); intent.putExtra(TvCommonConstants.EXTRA_INPUT_ID, inputId); Intent tvActivityIntent = new Intent(); tvActivityIntent.setComponent(new ComponentName(context, TV_ACTIVITY_CLASS_NAME)); intent.putExtra(TvCommonConstants.EXTRA_ACTIVITY_AFTER_COMPLETION, tvActivityIntent); return intent; }
From source file:com.felkertech.n.cumulustv.activities.MainActivity.java
@Override public void onConnected(Bundle bundle) { Log.d(TAG, "onConnected"); if (md != null) { if (md.isShowing()) { try { md.dismiss();/* w ww. ja va 2 s. com*/ } catch (Exception e) { e.printStackTrace(); } } } sm.setGoogleDriveSyncable(gapi, new DriveSettingsManager.GoogleDriveListener() { @Override public void onActionFinished(boolean cloudToLocal) { Log.d(TAG, "Sync req after drive action"); final String info = TvContract.buildInputId(ActivityUtils.TV_INPUT_SERVICE); SyncUtils.requestSync(MainActivity.this, info); if (cloudToLocal) { Toast.makeText(MainActivity.this, R.string.downloaded, Toast.LENGTH_SHORT).show(); } else { Toast.makeText(MainActivity.this, R.string.uploaded, Toast.LENGTH_SHORT).show(); } } }); //Enable GDrive if (DEBUG) { Log.d(TAG, sm.getString(R.string.sm_google_drive_id) + "<< for onConnected"); } if (sm.getString(R.string.sm_google_drive_id).isEmpty()) { //We need a new file new MaterialDialog.Builder(MainActivity.this).title(R.string.create_syncable_file) .content(R.string.create_syncable_file_description).positiveText(R.string.ok) .negativeText(R.string.no).callback(new MaterialDialog.ButtonCallback() { @Override public void onPositive(MaterialDialog dialog) { super.onPositive(dialog); Drive.DriveApi.newDriveContents(gapi).setResultCallback(driveContentsCallback); } }).show(); } else { //Great, user already has sync enabled, let's resync ActivityUtils.readDriveData(MainActivity.this, gapi); } }
From source file:com.felkertech.n.ActivityUtils.java
private static void actuallyWriteData(final Context context, GoogleApiClient gapi) { DriveSettingsManager sm = new DriveSettingsManager(context); sm.setGoogleDriveSyncable(gapi, new DriveSettingsManager.GoogleDriveListener() { @Override/* w ww. jav a 2s . c o m*/ public void onActionFinished(boolean cloudToLocal) { Log.d(TAG, "Action finished " + cloudToLocal); } }); try { sm.writeToGoogleDrive(DriveId.decodeFromString(sm.getString(R.string.sm_google_drive_id)), ChannelDatabase.getInstance(context).toString()); GoogleDriveBroadcastReceiver.changeStatus(context, GoogleDriveBroadcastReceiver.EVENT_UPLOAD_COMPLETE); final String info = TvContract.buildInputId(TV_INPUT_SERVICE); SyncUtils.requestSync(context, info); } catch (Exception e) { // Probably invalid drive id. No worries, just let someone know Log.e(TAG, e.getMessage() + ""); Toast.makeText(context, R.string.invalid_file, Toast.LENGTH_SHORT).show(); } }
From source file:com.felkertech.n.ActivityUtils.java
public static void readDriveData(@NonNull Context context, GoogleApiClient gapi) { DriveSettingsManager sm = new DriveSettingsManager(context); sm.setGoogleDriveSyncable(gapi, null); DriveId did;//w w w . j av a 2 s . com try { did = DriveId.decodeFromString(sm.getString(R.string.sm_google_drive_id)); } catch (Exception e) { Toast.makeText(context, R.string.invalid_file, Toast.LENGTH_SHORT).show(); return; } sm.readFromGoogleDrive(did, ChannelDatabase.KEY); GoogleDriveBroadcastReceiver.changeStatus(context, GoogleDriveBroadcastReceiver.EVENT_DOWNLOAD_COMPLETE); final String info = TvContract.buildInputId(TV_INPUT_SERVICE); SyncUtils.requestSync(context, info); }
From source file:com.android.tv.tuner.setup.TunerSetupActivity.java
/** * Returns a {@link Intent} to launch the tuner TV input service. * * @param context a {@link Context} instance */// w w w . j ava2 s .c o m public static Intent createSetupActivity(Context context) { String inputId = TvContract .buildInputId(new ComponentName(context.getPackageName(), TunerTvInputService.class.getName())); // Make an intent to launch the setup activity of TV tuner input. Intent intent = TvCommonUtils.createSetupIntent(new Intent(context, TunerSetupActivity.class), inputId); intent.putExtra(TvCommonConstants.EXTRA_INPUT_ID, inputId); Intent tvActivityIntent = new Intent(); tvActivityIntent.setComponent(new ComponentName(context, TV_ACTIVITY_CLASS_NAME)); intent.putExtra(TvCommonConstants.EXTRA_ACTIVITY_AFTER_COMPLETION, tvActivityIntent); return intent; }
From source file:com.felkertech.n.tv.fragments.LeanbackFragment.java
@Override public void onConnected(Bundle bundle) { Log.d(TAG, "onConnected"); sm.setGoogleDriveSyncable(gapi, new DriveSettingsManager.GoogleDriveListener() { @Override/*from w w w . java2s. c om*/ public void onActionFinished(boolean cloudToLocal) { Log.d(TAG, "Sync req after drive action"); final String info = TvContract.buildInputId(ActivityUtils.TV_INPUT_SERVICE); SyncUtils.requestSync(mActivity, info); if (cloudToLocal) { Toast.makeText(getActivity(), R.string.download_complete, Toast.LENGTH_SHORT).show(); } else { Toast.makeText(getActivity(), R.string.upload_complete, Toast.LENGTH_SHORT).show(); } } }); //Enable GDrive Log.d(TAG, sm.getString(R.string.sm_google_drive_id) + "<< for onConnected"); if (sm.getString(R.string.sm_google_drive_id).isEmpty()) { //We need a new file ActivityUtils.createDriveData(mActivity, gapi, driveContentsCallback); } else { //Great, user already has sync enabled, let's resync ActivityUtils.readDriveData(mActivity, gapi); Handler h = new Handler(Looper.getMainLooper()) { @Override public void handleMessage(Message msg) { super.handleMessage(msg); refreshUI(); } }; h.sendEmptyMessageDelayed(0, 4000); } }