本文整理汇总了Java中android.content.Intent.getByteArrayExtra方法的典型用法代码示例。如果您正苦于以下问题:Java Intent.getByteArrayExtra方法的具体用法?Java Intent.getByteArrayExtra怎么用?Java Intent.getByteArrayExtra使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.content.Intent
的用法示例。
在下文中一共展示了Intent.getByteArrayExtra方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onReceive
import android.content.Intent; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
// switch() doesn't support strings in older JDK.
if (ACTION_START.equals(action)) {
clearOutputs();
addView(getColoredView(LIGHTBLUE, "Request started"));
} else if (ACTION_FINISH.equals(action)) {
addView(getColoredView(LIGHTBLUE, "Request finished"));
} else if (ACTION_CANCEL.equals(action)) {
addView(getColoredView(LIGHTBLUE, "Request cancelled"));
} else if (ACTION_RETRY.equals(action)) {
addView(getColoredView(LIGHTBLUE, "Request retried"));
} else if (ACTION_FAILURE.equals(action) || ACTION_SUCCESS.equals(action)) {
debugThrowable(LOG_TAG, (Throwable) intent.getSerializableExtra(ExampleIntentService.INTENT_THROWABLE));
if (ACTION_SUCCESS.equals(action)) {
debugStatusCode(LOG_TAG, intent.getIntExtra(ExampleIntentService.INTENT_STATUS_CODE, 0));
debugHeaders(LOG_TAG, IntentUtil.deserializeHeaders(intent.getStringArrayExtra(ExampleIntentService.INTENT_HEADERS)));
byte[] returnedBytes = intent.getByteArrayExtra(ExampleIntentService.INTENT_DATA);
if (returnedBytes != null) {
debugResponse(LOG_TAG, new String(returnedBytes));
}
}
}
}
示例2: parseActivityResult
import android.content.Intent; //导入方法依赖的package包/类
/**
* <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;
}
示例3: extract
import android.content.Intent; //导入方法依赖的package包/类
/**
* Attempts to extract a protocol buffer from the specified extra.
* @throws MalformedDataException if the intent is null, the extra is missing or not a byte
* array, or the protocol buffer could not be parsed.
*/
@NonNull
public static <T extends MessageLite> T extract(
@NonNull String extraName,
@NonNull Parser<T> protoParser,
@NonNull String failureDescription,
@Nullable Intent intent)
throws MalformedDataException {
if (intent == null) {
throw new MalformedDataException(failureDescription);
}
byte[] protoBytes = intent.getByteArrayExtra(extraName);
if (protoBytes == null) {
throw new MalformedDataException(failureDescription);
}
try {
return protoParser.parseFrom(protoBytes);
} catch (IOException ex) {
throw new MalformedDataException(failureDescription, ex);
}
}
示例4: onCreate
import android.content.Intent; //导入方法依赖的package包/类
@Override
@SuppressWarnings("ConstantConditions")
public void onCreate(@Nullable Bundle bundle) {
super.onCreate(bundle);
Intent i = getIntent();
byte[] b = i.getByteArrayExtra(GROUP_ID);
if (b == null) throw new IllegalStateException("No GroupId");
groupId = new GroupId(b);
button = (Button) findViewById(R.id.revealButton);
button.setOnClickListener(this);
button.setEnabled(false);
if (bundle == null) {
showInitialFragment(RevealContactsFragment.newInstance(groupId));
}
}
示例5: onCreate
import android.content.Intent; //导入方法依赖的package包/类
@Override
public void onCreate(@Nullable final Bundle state) {
super.onCreate(state);
setContentView(R.layout.activity_sharing_status);
Intent i = getIntent();
byte[] b = i.getByteArrayExtra(GROUP_ID);
if (b == null) throw new IllegalStateException("No GroupId in intent.");
groupId = new GroupId(b);
list = (BriarRecyclerView) findViewById(R.id.list);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
list.setLayoutManager(linearLayoutManager);
adapter = new MemberListAdapter(this);
list.setAdapter(adapter);
TextView info = (TextView) findViewById(R.id.info);
info.setText(R.string.sharing_status_groups);
}
示例6: parseActivityResult
import android.content.Intent; //导入方法依赖的package包/类
/**
* <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(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;
}
示例7: parseActivityResult
import android.content.Intent; //导入方法依赖的package包/类
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;
}
示例8: toResultIntentData
import android.content.Intent; //导入方法依赖的package包/类
@Test
public void toResultIntentData() throws Exception {
HintRetrieveResult result = new HintRetrieveResult.Builder(
HintRetrieveResult.CODE_HINT_SELECTED)
.setHint(HINT)
.setAdditionalProperties(ValidAdditionalProperties.make())
.build();
Intent intent = result.toResultDataIntent();
assertThat(intent.hasExtra(ProtocolConstants.EXTRA_HINT_RESULT));
byte[] data = intent.getByteArrayExtra(ProtocolConstants.EXTRA_HINT_RESULT);
HintRetrieveResult readResult = HintRetrieveResult.fromProtobufBytes(data);
assertThat(readResult.getResultCode()).isEqualTo(HintRetrieveResult.CODE_HINT_SELECTED);
assertThat(readResult.getHint()).isNotNull();
ValidAdditionalProperties.assertEquals(readResult.getAdditionalProperties());
}
示例9: onCreate
import android.content.Intent; //导入方法依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = getIntent();
byte[] deviceEngagementData = intent.getByteArrayExtra("deviceEngagement");
try {
deviceEngagement = new DeviceEngagement(new TLVData(deviceEngagementData));
} catch (IOException e) {
e.printStackTrace();
}
final InterchangeProfile transferInterchange = deviceEngagement.getTransferInterchangeProfile();
dataMinimizationParameter = deviceEngagement.getInterfaceIndependentProfile().dataMinimizationParameter;
progressDialog = createTransferProgressDialog(transferInterchange);
progressDialog.show();
if (transferInterchange instanceof InterchangeProfileBLE) {
connection = new BLEConnection(this, ((InterchangeProfileBLE) transferInterchange).antiCollisionIdentifier);
} else if (transferInterchange instanceof InterchangeProfileNFC) {
connection = new NFCLicenseTransferConnection(this);
} else if (transferInterchange instanceof InterchangeProfileWD) {
connection = new WiFiDirectConnection(this, ((InterchangeProfileWD) transferInterchange).MAC);
} else {
throw new UnsupportedOperationException("transferInterchange not supported");
}
}
示例10: onReceive
import android.content.Intent; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
byte[] responseBytes = intent.getByteArrayExtra(QueryUtil.EXTRA_RESPONSE_MESSAGE);
if (responseBytes == null) {
Log.w(LOG_TAG, "Received query response without a defined message");
return;
}
BroadcastQueryResponse response;
try {
response = BroadcastQueryResponse.parseFrom(responseBytes);
} catch (IOException e) {
Log.w(LOG_TAG, "Unable to parse query response message");
return;
}
String responder = mPendingQuery.mRespondersById.get(response.getResponseId());
if (responder == null) {
Log.w(LOG_TAG, "Received response from unknown responder");
return;
}
if (!mPendingQuery.mPendingResponses.remove(response.getResponseId())) {
Log.w(LOG_TAG, "Duplicate response received; ignoring");
return;
}
if (response.getResponseMessage() != null) {
QueryResponse queryResponse = new QueryResponse(
responder,
response.getResponseId(),
response.getResponseMessage().toByteArray());
mPendingQuery.mResponses.put(responder, queryResponse);
}
if (mPendingQuery.mPendingResponses.isEmpty()) {
mPendingQuery.complete();
}
}
示例11: mimeBuildSignedMessage
import android.content.Intent; //导入方法依赖的package包/类
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);
}
示例12: onCreate
import android.content.Intent; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fruit);
Intent intent = getIntent();
String fruitName = intent.getStringExtra(FRUIT_NAME);
int fruitImageId = intent.getIntExtra(FRUIT_IMAGE_ID, 0);
String fruitinfo = intent.getStringExtra(FRUIT_INFO);
byte[] in = intent.getByteArrayExtra(FRUIT_IMAGE);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
CollapsingToolbarLayout collapsingToolbar = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
ImageView fruitImageView = (ImageView) findViewById(R.id.fruit_image_view);
TextView fruitContentText = (TextView) findViewById(R.id.fruit_content_text);
setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
}
collapsingToolbar.setTitle(fruitName);
if(fruitImageId==0)
{
Bitmap fruitimage = BitmapFactory.decodeByteArray(in, 0, in.length);
fruitImageView.setImageBitmap(fruitimage);
}
else Glide.with(this).load(fruitImageId).into(fruitImageView);
String fruitContent = generateFruitContent(fruitinfo);
fruitContentText.setText(fruitContent);
}
示例13: onCreate
import android.content.Intent; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
Intent i = getIntent();
byte[] g = i.getByteArrayExtra(GROUP_ID);
if (g == null) throw new IllegalStateException("No GroupId in intent.");
groupId = new GroupId(g);
if (bundle == null) {
showInitialFragment(GroupInviteFragment.newInstance(groupId));
}
}
示例14: toResultDataIntent_withValidResult_returnsValidIntent
import android.content.Intent; //导入方法依赖的package包/类
@Test
public void toResultDataIntent_withValidResult_returnsValidIntent() throws Exception {
final Intent resultIntent = ValidResult.INSTANCE.toResultDataIntent();
final byte[] encodedResult =
resultIntent.getByteArrayExtra(ProtocolConstants.EXTRA_SAVE_RESULT);
ValidResult.assertEqualTo(CredentialSaveResult.fromProtobufBytes(encodedResult));
}
示例15: getCredentialRetrieveResult
import android.content.Intent; //导入方法依赖的package包/类
/**
* Returns the result of a {@link CredentialRetrieveResult}.
*
* <pre>{@code
* CredentialClient client = CredentialClient.getInstance(getContext());
*
* // ...
* @Override
* public void onActivityResult(int requestCode, int resultCode, Intent data) {
* super.onActivityResult(requestCode, resultCode, data);
* if (RC_RETRIEVE_CREDENTIAL == requestCode) {
* CredentialRetrieveResult result = client.getCredentialRetrieveResult(data);
* if (result.isSuccessful()) {
* // A credential was retrieved, you may automatically sign the user in.
* result.getCredential();
* } else {
* // A credential was not retrieved, you may look at the result code to determine why
* // and decide what step to take next. For example, result code may inform you of the
* // user's intent such as CredentialRetrieveResult.CODE_USER_CANCELED.
* result.getResultCode();
* }
* }
* }
* }</pre>
*
*
* @see #getCredentialRetrieveIntent(CredentialRetrieveRequest)
*/
@NonNull
public CredentialRetrieveResult getCredentialRetrieveResult(
@Nullable Intent resultData) {
if (resultData == null) {
Log.i(LOG_TAG, "resultData is null, returning default response");
return CredentialRetrieveResult.UNKNOWN;
}
if (!resultData.hasExtra(EXTRA_RETRIEVE_RESULT)) {
Log.i(LOG_TAG, "retrieve result missing from response, returning default response");
return CredentialRetrieveResult.UNKNOWN;
}
byte[] resultBytes = resultData.getByteArrayExtra(EXTRA_RETRIEVE_RESULT);
if (resultBytes == null) {
Log.i(LOG_TAG, "No retrieve result found in result data, returning default response");
return CredentialRetrieveResult.UNKNOWN;
}
try {
CredentialRetrieveResult result =
CredentialRetrieveResult.fromProtobufBytes(resultBytes);
// Once a successfully retrieve result has been handled, re-enable auto sign-in.
if (CredentialRetrieveResult.CODE_CREDENTIAL_SELECTED == result.getResultCode()) {
mDeviceState.setIsAutoSignInDisabled(false);
}
return result;
} catch (MalformedDataException ex) {
Log.e(LOG_TAG, "validation of result proto failed, returning default response", ex);
return CredentialRetrieveResult.UNKNOWN;
}
}