List of usage examples for android.content Intent hasExtra
public boolean hasExtra(String name)
From source file:Main.java
/** * Extracts the {@link Uri url} out of an attachment upload. The url is part of the result {@link Intent} in {@link Activity#onActivityResult()} of a former * {@link #startAttachmentActivity()} call. * // w w w .ja va2 s .c om * @param activityResultIntent * Result {@link Intent} from {@link Activity#onActivityResult(int, int, Intent)}. * @return the upload url as {@link Uri} or null, if the result {@link Intent} contains no url. */ public static Uri getUrlFromResult(Intent activityResultIntent) { Uri url = activityResultIntent.getData(); if (url == null) { if (activityResultIntent.hasExtra(EXTRAS_URL)) { url = Uri.parse(activityResultIntent.getStringExtra(EXTRAS_URL)); } } return url; }
From source file:com.andremion.heroes.ui.section.view.SectionActivity.java
public static int getType(int resultCode, Intent data) { if (resultCode == RESULT_OK && data != null && data.hasExtra(EXTRA_TYPE)) { return data.getIntExtra(EXTRA_TYPE, EXTRA_NOT_FOUND); }//w w w . j a v a 2 s. com return EXTRA_NOT_FOUND; }
From source file:com.andremion.heroes.ui.section.view.SectionActivity.java
public static int getPosition(int resultCode, Intent data) { if (resultCode == RESULT_OK && data != null && data.hasExtra(EXTRA_POSITION)) { return data.getIntExtra(EXTRA_POSITION, EXTRA_NOT_FOUND); }/*from w w w . j a va 2 s. c o m*/ return EXTRA_NOT_FOUND; }
From source file:com.nestapi.lib.UserAuthActivity.java
static boolean hasAccessToken(Intent data) { return data != null && data.hasExtra(ACCESS_TOKEN_KEY); }
From source file:com.andremion.louvre.preview.PreviewActivity.java
public static int getPosition(int resultCode, Intent data) { if (resultCode == RESULT_OK && data != null && data.hasExtra(EXTRA_POSITION)) { return data.getIntExtra(EXTRA_POSITION, NO_POSITION); }// ww w. j a v a2 s . c om return NO_POSITION; }
From source file:de.dreier.mytargets.utils.transitions.FabTransform.java
/** * Create a {@link FabTransform} from the supplied {@code activity} extras and set as its * shared element enter/return transition. *//* www . ja v a 2 s .c o m*/ static boolean setup(@NonNull Activity activity, @Nullable View target) { final Intent intent = activity.getIntent(); if (!intent.hasExtra(EXTRA_FAB_COLOR_RES) || !intent.hasExtra(EXTRA_FAB_ICON_RES_ID)) { return false; } final int colorRes = intent.getIntExtra(EXTRA_FAB_COLOR_RES, R.color.colorAccent); final int icon = intent.getIntExtra(EXTRA_FAB_ICON_RES_ID, -1); final int color = ContextCompat.getColor(activity, colorRes); final FabTransform sharedEnter = new FabTransform(color, icon); if (target != null) { sharedEnter.addTarget(target); } activity.getWindow().setSharedElementEnterTransition(sharedEnter); return true; }
From source file:ameircom.keymedia.Activity.transition.FabTransform.java
/** * Create a {@link FabTransform} from the supplied {@code activity} extras and set as its * shared element enter/return transition. *//*from w ww. j ava2s . c o m*/ public static boolean setup(@NonNull Activity activity, @Nullable View target) { final Intent intent = activity.getIntent(); if (!intent.hasExtra(EXTRA_FAB_COLOR) || !intent.hasExtra(EXTRA_FAB_ICON_RES_ID)) { return false; } final int color = intent.getIntExtra(EXTRA_FAB_COLOR, Color.TRANSPARENT); final int icon = intent.getIntExtra(EXTRA_FAB_ICON_RES_ID, -1); final FabTransform sharedEnter = new FabTransform(color, icon); if (target != null) { sharedEnter.addTarget(target); } activity.getWindow().setSharedElementEnterTransition(sharedEnter); return true; }
From source file:ccv.checkhelzio.nuevaagendacucsh.transitions.FabTransition.java
/** * Create a {@link FabTransition} from the supplied {@code activity} extras and set as its * shared element enter/return transition. *///w w w . j av a 2 s . c om public static boolean setup(@NonNull Activity activity, @Nullable View target) { final Intent intent = activity.getIntent(); if (!intent.hasExtra(EXTRA_FAB_COLOR) || !intent.hasExtra(EXTRA_FAB_ICON_RES_ID)) { return false; } final int color = intent.getIntExtra(EXTRA_FAB_COLOR, Color.TRANSPARENT); final int icon = intent.getIntExtra(EXTRA_FAB_ICON_RES_ID, -1); final FabTransition sharedEnter = new FabTransition(color, icon); if (target != null) { sharedEnter.addTarget(target); } activity.getWindow().setSharedElementEnterTransition(sharedEnter); return true; }
From source file:de.domjos.schooltools.helper.Helper.java
public static void receiveBroadCast(Context context, Intent intent, int id) { Bundle bundle = intent.getExtras();//from w w w . jav a 2 s . c o m if (bundle != null) { if (intent.hasExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS)) { int[] ids = bundle.getIntArray(AppWidgetManager.EXTRA_APPWIDGET_IDS); AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context); appWidgetManager.notifyAppWidgetViewDataChanged(ids, id); } } }
From source file:androidx.media.session.MediaButtonReceiver.java
/** * Extracts any available {@link KeyEvent} from an {@link Intent#ACTION_MEDIA_BUTTON} * intent, passing it onto the {@link MediaSessionCompat} using * {@link MediaControllerCompat#dispatchMediaButtonEvent(KeyEvent)}, which in turn * will trigger callbacks to the {@link MediaSessionCompat.Callback} registered via * {@link MediaSessionCompat#setCallback(MediaSessionCompat.Callback)}. * @param mediaSessionCompat A {@link MediaSessionCompat} that has a * {@link MediaSessionCompat.Callback} set. * @param intent The intent to parse./* w w w.j a v a 2s. co m*/ * @return The extracted {@link KeyEvent} if found, or null. */ public static KeyEvent handleIntent(MediaSessionCompat mediaSessionCompat, Intent intent) { if (mediaSessionCompat == null || intent == null || !Intent.ACTION_MEDIA_BUTTON.equals(intent.getAction()) || !intent.hasExtra(Intent.EXTRA_KEY_EVENT)) { return null; } KeyEvent ke = intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT); MediaControllerCompat mediaController = mediaSessionCompat.getController(); mediaController.dispatchMediaButtonEvent(ke); return ke; }