Example usage for android.content Intent getByteArrayExtra

List of usage examples for android.content Intent getByteArrayExtra

Introduction

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

Prototype

public byte[] getByteArrayExtra(String name) 

Source Link

Document

Retrieve extended data from the intent.

Usage

From source file:Main.java

public static Bitmap Bytes2Bitmap(Intent intent) {
    byte[] buff = intent.getByteArrayExtra("bitmap");
    Bitmap bm = BitmapFactory.decodeByteArray(buff, 0, buff.length);
    return bm;/*from  ww  w.  j  a v a 2s  . com*/
}

From source file:Main.java

public static Bitmap bytes2Bitmap(Intent intent) {
    byte[] buff = intent.getByteArrayExtra("bitmap");
    Bitmap bm = BitmapFactory.decodeByteArray(buff, 0, buff.length);
    return bm;/*  w ww  .  ja v a  2  s  .  c om*/
}

From source file:Main.java

public static byte[] getByteArrayExtra(Intent intent, String name) {
    if (!hasIntent(intent) || !hasExtra(intent, name))
        return null;
    return intent.getByteArrayExtra(name);
}

From source file:org.chromium.chrome.browser.util.IntentUtils.java

/**
 * Just like {@link Intent#getByteArrayExtra(String)} but doesn't throw exceptions.
 *//*from ww  w .jav  a 2s  .c o m*/
public static byte[] safeGetByteArrayExtra(Intent intent, String name) {
    try {
        return intent.getByteArrayExtra(name);
    } catch (Throwable t) {
        // Catches un-parceling exceptions.
        Log.e(TAG, "getByteArrayExtra failed on intent " + intent);
        return null;
    }
}

From source file:com.example.reedme.android.IntentIntegrator.java

/**
 * <p>Call this from your {@link Activity}'s
 * {@link Activity#onActivityResult(int, int, Intent)} method.</p>
 *
 * @param requestCode request code from {@code onActivityResult()}
 * @param resultCode  result code from {@code onActivityResult()}
 * @param intent      {@link Intent} from {@code onActivityResult()}
 * @return null if the event handled here was not related to this class, or
 * else an {@link IntentResult} containing the result of the scan. If the user cancelled scanning,
 * the fields will be null.// w w  w  .j  a va2  s.  c  om
 */
public static IntentResult parseActivityResult(int requestCode, int resultCode, Intent intent) {
    if (requestCode == REQUEST_CODE) {
        if (resultCode == Activity.RESULT_OK) {
            String contents = intent.getStringExtra(Intents.Scan.RESULT);
            String formatName = intent.getStringExtra(Intents.Scan.RESULT_FORMAT);
            byte[] rawBytes = intent.getByteArrayExtra(Intents.Scan.RESULT_BYTES);
            int intentOrientation = intent.getIntExtra(Intents.Scan.RESULT_ORIENTATION, Integer.MIN_VALUE);
            Integer orientation = intentOrientation == Integer.MIN_VALUE ? null : intentOrientation;
            String errorCorrectionLevel = intent.getStringExtra(Intents.Scan.RESULT_ERROR_CORRECTION_LEVEL);
            String barcodeImagePath = intent.getStringExtra(Intents.Scan.RESULT_BARCODE_IMAGE_PATH);
            return new IntentResult(contents, formatName, rawBytes, orientation, errorCorrectionLevel,
                    barcodeImagePath);
        }
        return new IntentResult();
    }
    return null;
}

From source file:com.google.zxing.integration.android.CustomerIntentIntegrator.java

/**
 * <p>Call this from your {@link Activity}'s
 * {@link Activity#onActivityResult(int, int, Intent)} method.</p>
 *
 * @param requestCode request code from {@code onActivityResult()}
 * @param resultCode  result code from {@code onActivityResult()}
 * @param intent      {@link Intent} from {@code onActivityResult()}
 * @return null if the event handled here was not related to this class, or
 * else an {@link IntentResult} containing the result of the scan. If the user cancelled scanning,
 * the fields will be null.//from w  w w  .jav  a 2 s  .  c  o m
 */
public static CustomerIntentResult parseActivityResult(int requestCode, int resultCode, Intent intent) {
    if (requestCode == REQUEST_CODE) {
        if (resultCode == Activity.RESULT_OK) {
            String contents = intent.getStringExtra(Intents.Scan.RESULT);
            String formatName = intent.getStringExtra(Intents.Scan.RESULT_FORMAT);
            byte[] rawBytes = intent.getByteArrayExtra(Intents.Scan.RESULT_BYTES);
            int intentOrientation = intent.getIntExtra(Intents.Scan.RESULT_ORIENTATION, Integer.MIN_VALUE);
            Integer orientation = intentOrientation == Integer.MIN_VALUE ? null : intentOrientation;
            String errorCorrectionLevel = intent.getStringExtra(Intents.Scan.RESULT_ERROR_CORRECTION_LEVEL);
            String barcodeImagePath = intent.getStringExtra(Intents.Scan.RESULT_BARCODE_IMAGE_PATH);
            return new CustomerIntentResult(contents, formatName, rawBytes, orientation, errorCorrectionLevel,
                    barcodeImagePath);
        }
        return new CustomerIntentResult();
    }
    return null;
}

From source file:com.lsh123.zxing.integration.android.IntentIntegrator.java

/**
 * <p>Call this from your {@link Activity}'s
 * {@link Activity#onActivityResult(int, int, Intent)} method.</p>
 *
 * @param requestCode request code from {@code onActivityResult()}
 * @param resultCode  result code from {@code onActivityResult()}
 * @param intent      {@link Intent} from {@code onActivityResult()}
 * @return null if the event handled here was not related to this class, or
 * else an {@link com.lsh123.zxing.integration.android.IntentResult} containing the result of the scan. If the user cancelled scanning,
 * the fields will be null.//from w  ww.  ja v  a  2  s.  com
 */
public static com.lsh123.zxing.integration.android.IntentResult parseActivityResult(int requestCode,
        int resultCode, Intent intent) {
    if (requestCode == REQUEST_CODE) {
        if (resultCode == Activity.RESULT_OK) {
            String contents = intent.getStringExtra(Intents.Scan.RESULT);
            String formatName = intent.getStringExtra(Intents.Scan.RESULT_FORMAT);
            byte[] rawBytes = intent.getByteArrayExtra(Intents.Scan.RESULT_BYTES);
            int intentOrientation = intent.getIntExtra(Intents.Scan.RESULT_ORIENTATION, Integer.MIN_VALUE);
            Integer orientation = intentOrientation == Integer.MIN_VALUE ? null : intentOrientation;
            String errorCorrectionLevel = intent.getStringExtra(Intents.Scan.RESULT_ERROR_CORRECTION_LEVEL);
            String barcodeImagePath = intent.getStringExtra(Intents.Scan.RESULT_BARCODE_IMAGE_PATH);
            return new com.lsh123.zxing.integration.android.IntentResult(contents, formatName, rawBytes,
                    orientation, errorCorrectionLevel, barcodeImagePath);
        }
        return new com.lsh123.zxing.integration.android.IntentResult();
    }
    return null;
}

From source file:com.google.zxing.integration.android.IntentIntegrator.java

/**
 * <p>Call this from your {@link Activity}'s
 * {@link Activity#onActivityResult(int, int, Intent)} method.</p>
 *
 * @param requestCode request code from {@code onActivityResult()}
 * @param resultCode  result code from {@code onActivityResult()}
 * @param intent      {@link Intent} from {@code onActivityResult()}
 * @return null if the event handled here was not related to this class, or
 * else an {@link IntentResult} containing the result of the scan. If the user cancelled scanning,
 * the fields will be null.//from w w w.  j av a  2s.  c  o m
 */
public static IntentResult parseActivityResult(int requestCode, int resultCode, Intent intent) {
    if (requestCode == REQUEST_CODE) {
        if (resultCode == Activity.RESULT_OK) {
            String contents = intent.getStringExtra(Intents.Scan.RESULT);
            String formatName = intent.getStringExtra(Intents.Scan.RESULT_FORMAT);
            String type = intent.getStringExtra(Intents.Scan.RESULT_TYPE);
            byte[] rawBytes = intent.getByteArrayExtra(Intents.Scan.RESULT_BYTES);
            int intentOrientation = intent.getIntExtra(Intents.Scan.RESULT_ORIENTATION, Integer.MIN_VALUE);
            Integer orientation = intentOrientation == Integer.MIN_VALUE ? null : intentOrientation;
            String errorCorrectionLevel = intent.getStringExtra(Intents.Scan.RESULT_ERROR_CORRECTION_LEVEL);
            return new IntentResult(contents, formatName, type, rawBytes, orientation, errorCorrectionLevel);
        }
        return new IntentResult();
    }
    return null;
}

From source file:cis350.blanket.IntentIntegrator.java

/**
 * <p>Call this from your {@link Activity}'s
 * {@link Activity#onActivityResult(int, int, Intent)} method.</p>
 *
 * @param requestCode request code from {@code onActivityResult()}
 * @param resultCode result code from {@code onActivityResult()}
 * @param intent {@link Intent} from {@code onActivityResult()}
 * @return null if the event handled here was not related to this class, or
 *  else an {@link IntentResult} containing the result of the scan. If the user cancelled scanning,
 *  the fields will be null.//from   www  .j a v a 2 s. com
 */
public static IntentResult parseActivityResult(int requestCode, int resultCode, Intent intent) {
    if (requestCode == REQUEST_CODE) {
        if (resultCode == Activity.RESULT_OK) {
            String contents = intent.getStringExtra("SCAN_RESULT");
            String formatName = intent.getStringExtra("SCAN_RESULT_FORMAT");
            byte[] rawBytes = intent.getByteArrayExtra("SCAN_RESULT_BYTES");
            int intentOrientation = intent.getIntExtra("SCAN_RESULT_ORIENTATION", Integer.MIN_VALUE);
            Integer orientation = intentOrientation == Integer.MIN_VALUE ? null : intentOrientation;
            String errorCorrectionLevel = intent.getStringExtra("SCAN_RESULT_ERROR_CORRECTION_LEVEL");
            return new IntentResult(contents, formatName, rawBytes, orientation, errorCorrectionLevel);
        }
        return new IntentResult();
    }
    return null;
}

From source file:com.google.zxing.integration.android.ScannerIntegrator.java

/**
 * <p>Call this from your {@link Activity}'s
 * {@link Activity#onActivityResult(int, int, Intent)} method.</p>
 *
 * @param requestCode request code from {@code onActivityResult()}
 * @param resultCode result code from {@code onActivityResult()}
 * @param intent {@link Intent} from {@code onActivityResult()}
 * @return null if the event handled here was not related to this class, or
 *  else an {@link ScannerResult} containing the result of the scan. If the user cancelled scanning,
 *  the fields will be null./*ww  w. j a  va 2s. com*/
 */
public static ScannerResult parseActivityResult(int requestCode, int resultCode, Intent intent) {
    if (requestCode == REQUEST_CODE) {
        if (resultCode == Activity.RESULT_OK) {
            String contents = intent.getStringExtra("SCAN_RESULT");
            String formatName = intent.getStringExtra("SCAN_RESULT_FORMAT");
            byte[] rawBytes = intent.getByteArrayExtra("SCAN_RESULT_BYTES");
            int intentOrientation = intent.getIntExtra("SCAN_RESULT_ORIENTATION", Integer.MIN_VALUE);
            Integer orientation = intentOrientation == Integer.MIN_VALUE ? null : intentOrientation;
            String errorCorrectionLevel = intent.getStringExtra("SCAN_RESULT_ERROR_CORRECTION_LEVEL");
            return new ScannerResult(contents, formatName, rawBytes, orientation, errorCorrectionLevel);
        }
        return new ScannerResult();
    }
    return null;
}