本文整理了Java中android.content.Intent.getByteArrayExtra()
方法的一些代码示例,展示了Intent.getByteArrayExtra()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Intent.getByteArrayExtra()
方法的具体详情如下:
包路径:android.content.Intent
类名称:Intent
方法名:getByteArrayExtra
暂无
代码示例来源:origin: commonsguy/cw-omnibus
/**
* <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.
*/
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;
}
代码示例来源:origin: commonsguy/cw-omnibus
@Override
public void onReceive(Context ctxt, Intent i) {
Thingy thingy=
Parcelables.toParcelable(i.getByteArrayExtra(EXTRA_THINGY),
Thingy.CREATOR);
if (i.getAction() == null) {
ScheduledService.enqueueWork(ctxt);
}
else {
scheduleAlarms(ctxt);
}
}
代码示例来源:origin: journeyapps/zxing-android-embedded
/**
* Parse activity result, without checking the request code.
*
* @param resultCode result code from {@code onActivityResult()}
* @param intent {@link Intent} from {@code onActivityResult()}
* @return an {@link IntentResult} containing the result of the scan. If the user cancelled scanning,
* the fields will be null.
*/
public static IntentResult parseActivityResult(int resultCode, Intent intent) {
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();
}
代码示例来源:origin: k9mail/k-9
private void mimeBuildSignedMessage(@NonNull BodyPart signedBodyPart, Intent result) throws MessagingException {
if (!cryptoStatus.isSigningEnabled()) {
throw new IllegalStateException("call to mimeBuildSignedMessage while signing isn't enabled!");
}
byte[] signedData = result.getByteArrayExtra(OpenPgpApi.RESULT_DETACHED_SIGNATURE);
if (signedData == null) {
throw new MessagingException("didn't find expected RESULT_DETACHED_SIGNATURE in api call result");
}
MimeMultipart multipartSigned = createMimeMultipart();
multipartSigned.setSubType("signed");
multipartSigned.addBodyPart(signedBodyPart);
multipartSigned.addBodyPart(
new MimeBodyPart(new BinaryMemoryBody(signedData, MimeUtil.ENC_7BIT),
"application/pgp-signature; name=\"signature.asc\""));
MimeMessageHelper.setBody(currentProcessedMimeMessage, multipartSigned);
String contentType = String.format(
"multipart/signed; boundary=\"%s\";\r\n protocol=\"application/pgp-signature\"",
multipartSigned.getBoundary());
if (result.hasExtra(OpenPgpApi.RESULT_SIGNATURE_MICALG)) {
String micAlgParameter = result.getStringExtra(OpenPgpApi.RESULT_SIGNATURE_MICALG);
contentType += String.format("; micalg=\"%s\"", micAlgParameter);
} else {
Timber.e("missing micalg parameter for pgp multipart/signed!");
}
currentProcessedMimeMessage.setHeader(MimeHeader.HEADER_CONTENT_TYPE, contentType);
}
代码示例来源:origin: k9mail/k-9
ParcelableUtil.unmarshall(intent.getByteArrayExtra(EXTRA_SEARCH), LocalSearch.CREATOR) : null;
noThreading = intent.getBooleanExtra(EXTRA_NO_THREADING, false);
代码示例来源:origin: google/ExoPlayer
byte[] actionData = intent.getByteArrayExtra(KEY_DOWNLOAD_ACTION);
if (actionData == null) {
Log.e(TAG, "Ignoring ADD action with no action data");
代码示例来源:origin: DeviceConnect/DeviceConnect-Android
/**
* リクエストから画像ファイルのバイナリを取得する.
*
* @param request リクエストパラメータ
* @return 画像ファイルのバイナリ。無い場合はnullを返す。
*/
public static byte[] getData(final Intent request) {
return request.getByteArrayExtra(PARAM_DATA);
}
代码示例来源:origin: kalaspuffar/secure-quick-reliable-login
/**
* Wrapper function if we ever need to read more than one byte segment in the future.
*
* @param data String from the QR code read.
* @return The string without any extra information.
*/
public static byte[] readSQRLQRCode(Intent data) throws FormatException {
return data.getByteArrayExtra("SCAN_RESULT_BYTE_SEGMENTS_0");
}
代码示例来源:origin: DeviceConnect/DeviceConnect-Android
/**
* リクエストから画像ファイルのバイナリを取得する.
*
* @param request リクエストパラメータ
* @return 画像ファイルのバイナリ。無い場合はnullを返す。
*/
public static byte[] getData(final Intent request) {
return request.getByteArrayExtra(PARAM_DATA);
}
代码示例来源:origin: stackoverflow.com
private class NdefReaderTask extends AsyncTask<Intent, Void, String> {
@Override
protected String doInBackground(Intent... params) {
Intent intent = params[0];
Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
byte[] uid = intent.getByteArrayExtra(NfcAdapter.EXTRA_ID);
// ... //
}
代码示例来源:origin: stackoverflow.com
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
uid = (TextView) findViewById(R.id.UID);
Intent i = getIntent(); // get the intent that started us
if (NfcAdapter.ACTION_TECH_DISCOVERED.equals(i.getAction())) {
uid.setText(ByteArrayToHexString(i.getByteArrayExtra(NfcAdapter.EXTRA_ID)));
}
}
代码示例来源:origin: stackoverflow.com
Intent intent = getIntent();
ArrayList<byte[]> barray = new ArrayList<>();
int size = intent.getIntExtra("barray_size", 0);
for (int i = 0; i < size; i++) {
barray.add(intent.getByteArrayExtra("barray"+i));
}
代码示例来源:origin: derry/delion
/**
* Just like {@link Intent#getByteArrayExtra(String)} but doesn't throw exceptions.
*/
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;
}
}
代码示例来源:origin: JackWHLiu/jackknife
public static byte[] getByteArrayExtra(Intent intent, String name) {
if (intent != null || !hasExtra(intent, name)) return null;
return intent.getByteArrayExtra(name);
}
代码示例来源:origin: vipulasri/Artisto_capstone
@Override
public void onReceive(Context context, Intent intent) {
if(intent.getAction().equals(INTENT_ACTION)){
byte[] bytes = intent.getByteArrayExtra(EXTRA_ART);
Artwork artwork = ParcelableUtil.unmarshall(bytes, Artwork.CREATOR);
Log.e("Intent","->"+artwork.getTitle());
Intent showArtDetail = new Intent(context, ArtsDetailsActivity.class);
showArtDetail.putExtra(ArtsDetailsActivity.TAG_ARTWORK, artwork);
showArtDetail.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(showArtDetail);
}
super.onReceive(context, intent);
}
代码示例来源:origin: renyuneyun/Easer
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQCODE_WAIT_FOR_TAG && resultCode == Activity.RESULT_OK) {
Logger.d("got expected result. setting data");
byte[] tag_id = data.getByteArrayExtra(WaitForNfcActivity.EXTRA_ID);
editText.setText(NfcTagEventData.byteArray2hexString(tag_id));
}
}
代码示例来源:origin: skjolber/external-nfc-api
@Override
protected void onNfcIntentDetected(Intent intent, String action) {
if(intent.hasExtra(NfcAdapter.EXTRA_ID)) {
byte[] id = intent.getByteArrayExtra(NfcAdapter.EXTRA_ID);
Log.d(TAG, "Tag id " + toHexString(id));
setTagId(id);
} else {
Log.d(TAG, "No tag id");
setTagId(null);
}
}
代码示例来源:origin: xiaolongonly/Ticket-Analysis
public static byte[] getByteArrayExtra(Intent intent, String name) {
if (!hasIntent(intent) || !hasExtra(intent, name)) return null;
return intent.getByteArrayExtra(name);
}
代码示例来源:origin: ustwo/clockwise
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mWearableAPIHelper = new WearableAPIHelper(this, null);
setContentView(R.layout.permission_info);
mPermissionsRequest = PermissionsRequest.deserialize(getIntent().getByteArrayExtra(EXTRA_PERMISSION_REQUEST));
if(mPermissionsRequest == null || mPermissionsRequest.getRequestItems().size() == 0) {
throw new IllegalArgumentException("You must include at least one PermissionRequestItem in the EXTRA_PERMISSION_REQUEST");
} else {
mWearablePermission = mPermissionsRequest.getRequestItems().get(0);
init();
}
}
代码示例来源:origin: NordicSemiconductor/Android-nRF-Toolbox
@Override
protected void onStart() {
super.onStart();
final Intent intent = getIntent();
if (!isDeviceConnected() && intent.hasExtra(FeaturesActivity.EXTRA_ADDRESS)) {
final BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
final BluetoothDevice device = bluetoothAdapter.getRemoteDevice(getIntent().getByteArrayExtra(FeaturesActivity.EXTRA_ADDRESS));
onDeviceSelected(device, device.getName());
intent.removeExtra(FeaturesActivity.EXTRA_APP);
intent.removeExtra(FeaturesActivity.EXTRA_ADDRESS);
}
}
内容来源于网络,如有侵权,请联系作者删除!