當前位置: 首頁>>代碼示例>>Java>>正文


Java Intent.getByteArrayExtra方法代碼示例

本文整理匯總了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));
            }
        }
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:27,代碼來源:IntentServiceSample.java

示例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;
}
 
開發者ID:uhuru-mobile,項目名稱:mobile-store,代碼行數:31,代碼來源:IntentIntegrator.java

示例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);
    }
}
 
開發者ID:openid,項目名稱:OpenYOLO-Android,代碼行數:29,代碼來源:IntentProtocolBufferExtractor.java

示例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));
	}
}
 
開發者ID:rafjordao,項目名稱:Nird2,代碼行數:19,代碼來源:RevealContactsActivity.java

示例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);
}
 
開發者ID:rafjordao,項目名稱:Nird2,代碼行數:21,代碼來源:GroupMemberListActivity.java

示例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;
}
 
開發者ID:yinhaojun,項目名稱:ZxingForAndroid,代碼行數:33,代碼來源:IntentIntegrator.java

示例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;
}
 
開發者ID:MrNo-Body,項目名稱:ecam-app-android,代碼行數:20,代碼來源:IntentIntegrator.java

示例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());
}
 
開發者ID:openid,項目名稱:OpenYOLO-Android,代碼行數:18,代碼來源:HintRetrieveResultTest.java

示例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");
    }
}
 
開發者ID:mDL-ILP,項目名稱:mDL-ILP,代碼行數:29,代碼來源:AbstractLicenseActivity.java

示例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();
    }
}
 
開發者ID:openid,項目名稱:OpenYOLO-Android,代碼行數:40,代碼來源:BroadcastQueryClient.java

示例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);
}
 
開發者ID:philipwhiuk,項目名稱:q-mail,代碼行數:30,代碼來源:PgpMessageBuilder.java

示例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);
}
 
開發者ID:android-app-development-course,項目名稱:fruit,代碼行數:29,代碼來源:FruitActivity.java

示例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));
	}
}
 
開發者ID:rafjordao,項目名稱:Nird2,代碼行數:14,代碼來源:GroupInviteActivity.java

示例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));
}
 
開發者ID:openid,項目名稱:OpenYOLO-Android,代碼行數:9,代碼來源:CredentialSaveResultTest.java

示例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;
    }
}
 
開發者ID:openid,項目名稱:OpenYOLO-Android,代碼行數:63,代碼來源:CredentialClient.java


注:本文中的android.content.Intent.getByteArrayExtra方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。