Example usage for android.content Intent getParcelableExtra

List of usage examples for android.content Intent getParcelableExtra

Introduction

In this page you can find the example usage for android.content Intent getParcelableExtra.

Prototype

public <T extends Parcelable> T getParcelableExtra(String name) 

Source Link

Document

Retrieve extended data from the intent.

Usage

From source file:Main.java

public static Bitmap getBitmapFromIntent(Intent intent) {
    return intent.getParcelableExtra("data");
}

From source file:Main.java

public static String[] getTagType(Intent intent) {
    Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
    String[] techList = tag.getTechList();
    return techList;
}

From source file:com.laevatein.internal.misc.ui.FragmentUtils.java

public static <T extends Parcelable> T getIntentParcelableExtra(Fragment fragment, String key) {
    Activity activity = fragment.getActivity();
    Intent intent = activity.getIntent();
    return intent.getParcelableExtra(key);
}

From source file:Main.java

static public boolean isDisconnectedIntent(Intent intent) {
    boolean res = false;
    NetworkInfo networkInfo = (NetworkInfo) intent.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO);
    if (networkInfo != null) {
        NetworkInfo.State state = networkInfo.getState();
        res = (state.equals(NetworkInfo.State.DISCONNECTING) || state.equals(NetworkInfo.State.DISCONNECTED))
                && (networkInfo.getType() == ConnectivityManager.TYPE_WIFI);

    } else {//from w ww.  j  a  v a  2 s  . com
        int wifiState = intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE, WifiManager.WIFI_STATE_UNKNOWN);
        if (wifiState == WifiManager.WIFI_STATE_DISABLED || wifiState == WifiManager.WIFI_STATE_DISABLING) {
            res = true;
        }
    }
    return res;
}

From source file:Main.java

public static <T extends Parcelable> T getParcelableExtra(Intent intent, String name) {
    if (!hasIntent(intent) || !hasExtra(intent, name))
        return null;
    return intent.getParcelableExtra(name);
}

From source file:Main.java

/**
 * Returns import source uri based on the Intent.
 *//*from   ww  w  . j  a  va  2s  .co  m*/
static Uri getImportUri(Intent intent) {
    String action = intent.getAction();
    if (Intent.ACTION_SEND.equals(action)) {
        return intent.getParcelableExtra(Intent.EXTRA_STREAM);
    }
    if (Intent.ACTION_VIEW.equals(action)) {
        return intent.getData();
    }
    return null;
}

From source file:Main.java

private static Drawable getShortcutIcon(Context context, Intent shortcutIntent) {
    if (!shortcutIntent.hasExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE)) {
        return null;
    }//  ww w .j  av  a 2 s  . c  o  m
    try {
        Intent.ShortcutIconResource iconRes = shortcutIntent
                .getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE);
        Resources appRes = context.getPackageManager().getResourcesForApplication(iconRes.packageName);
        int resId = appRes.getIdentifier(iconRes.resourceName, null, null);
        return appRes.getDrawable(resId);
    } catch (Exception e) {
        e.printStackTrace();
    }

    return null;
}

From source file:Main.java

/**
 * For Activities which want to treat new Intents as Intents with a new Tag attached. If the given Intent has a Tag extra, the {@link #mTag} and
 * {@link #mUID} will be updated and a Toast message will be shown in the calling Context (Activity). This method will also check if the
 * device/tag supports Mifare Classic (see return values).
 * /*from ww  w  . ja  v  a2  s  .c  o  m*/
 * @param intent The Intent which should be checked for a new Tag.
 * @param context The Context in which the Toast will be shown.
 * @return <ul>
 *         <li>1 - The device/tag supports Mifare Classic</li>
 *         <li>0 - The device/tag does not support Mifare Classic</li>
 *         <li>-1 - Wrong Intent (action is not "ACTION_TECH_DISCOVERED").</li>
 *         </ul>
 * @see #mTag
 * @see #mUID
 */
public static int treatAsNewTag(Intent intent, Context context) {
    // Check if Intent has a NFC Tag.
    if (NfcAdapter.ACTION_TECH_DISCOVERED.equals(intent.getAction())) {
        Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
        mTag = tag;
        mUID = tag.getId();

        // Show Toast message with UID.
        //         String id = " (UID: ";
        //         id += byte2HexString(tag.getId());
        //         id += ")";
        //         Toast.makeText(context, id, Toast.LENGTH_LONG).show();

        // Return "1" if device supports Mifare Classic. "0" otherwise.
        return (Arrays.asList(tag.getTechList()).contains(MifareClassic.class.getName())) ? 1 : 0;
    }
    return -1;
}

From source file:com.devgmail.mitroshin.totutu.controllers.ListFragment.java

public static Station resultStationObject(Intent result) {
    return result.getParcelableExtra(EXTRA_REQUEST_STATION_OBJECT);
}

From source file:com.druk.bonjour.browser.ui.RegisterServiceActivity.java

public static BonjourService parseResult(Intent intent) {
    return intent.getParcelableExtra(SERVICE);
}