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


Java Intent.getParcelableArrayExtra方法代碼示例

本文整理匯總了Java中android.content.Intent.getParcelableArrayExtra方法的典型用法代碼示例。如果您正苦於以下問題:Java Intent.getParcelableArrayExtra方法的具體用法?Java Intent.getParcelableArrayExtra怎麽用?Java Intent.getParcelableArrayExtra使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.content.Intent的用法示例。


在下文中一共展示了Intent.getParcelableArrayExtra方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: readNfcTag

import android.content.Intent; //導入方法依賴的package包/類
/**
 * 讀取NFC標簽文本數據
 */
private void readNfcTag(Intent intent) {
    if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(intent.getAction())) {
        Parcelable[] rawMsgs = intent.getParcelableArrayExtra(
                NfcAdapter.EXTRA_NDEF_MESSAGES);
        NdefMessage msgs[] = null;
        int contentSize = 0;
        if (rawMsgs != null) {
            msgs = new NdefMessage[rawMsgs.length];
            for (int i = 0; i < rawMsgs.length; i++) {
                msgs[i] = (NdefMessage) rawMsgs[i];
                contentSize += msgs[i].toByteArray().length;
            }
        }
        try {
            if (msgs != null) {
                NdefRecord record = msgs[0].getRecords()[0];
                String textRecord = parseTextRecord(record);
                mTagText += textRecord + "\n\ntext\n" + contentSize + " bytes";
            }
        } catch (Exception e) {
        }
    }
}
 
開發者ID:jopenbox,項目名稱:android-nfc,代碼行數:27,代碼來源:ReadTextActivity.java

示例2: onNewIntent

import android.content.Intent; //導入方法依賴的package包/類
@Override
public void onNewIntent(Intent intent)
{
    super.onNewIntent(intent);

    if(intent.hasExtra(NfcAdapter.EXTRA_TAG ))
    {
        if(BackgroundTask.isNetworkAvailable(HubMain.this))
        {
            gifImageView.setVisibility(View.INVISIBLE);
            spinner.setVisibility(View.VISIBLE);
        }
        Parcelable[] parcelables = intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES);

        if(parcelables != null && parcelables.length > 0)
        {
            readTextfromMessage((NdefMessage)parcelables[0]);
        }
    }
}
 
開發者ID:ThomasDelaney,項目名稱:TapIn,代碼行數:21,代碼來源:HubMain.java

示例3: onCreate

import android.content.Intent; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    TaskStackBuilder builder = TaskStackBuilder.create(this);
    Intent proxyIntent = getIntent();
    if (!proxyIntent.hasExtra(EXTRA_INTENTS)) {
        finish();
        return;
    }

    for (Parcelable parcelable : proxyIntent.getParcelableArrayExtra(EXTRA_INTENTS)) {
        builder.addNextIntent((Intent) parcelable);
    }

    builder.startActivities();
    finish();
}
 
開發者ID:dreaminglion,項目名稱:iosched-reader,代碼行數:19,代碼來源:TaskStackBuilderProxyActivity.java

示例4: tryUpdateIntentFromBeam

import android.content.Intent; //導入方法依賴的package包/類
/**
 * Checks to see if the activity's intent ({@link android.app.Activity#getIntent()}) is
 * an NFC intent that the app recognizes. If it is, then parse the NFC message and set the
 * activity's intent (using {@link Activity#setIntent(android.content.Intent)}) to something
 * the app can recognize (i.e. a normal {@link Intent#ACTION_VIEW} intent).
 */
public static void tryUpdateIntentFromBeam(Activity activity) {
    Intent originalIntent = activity.getIntent();
    if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(originalIntent.getAction())) {
        Parcelable[] rawMsgs = originalIntent.getParcelableArrayExtra(
                NfcAdapter.EXTRA_NDEF_MESSAGES);
        NdefMessage msg = (NdefMessage) rawMsgs[0];
        // Record 0 contains the MIME type, record 1 is the AAR, if present.
        // In iosched, AARs are not present.
        NdefRecord mimeRecord = msg.getRecords()[0];
        if (ScheduleContract.makeContentItemType(
                ScheduleContract.Sessions.CONTENT_TYPE_ID).equals(
                new String(mimeRecord.getType()))) {
            // Re-set the activity's intent to one that represents session details.
            Intent sessionDetailIntent = new Intent(Intent.ACTION_VIEW,
                    Uri.parse(new String(mimeRecord.getPayload())));
            activity.setIntent(sessionDetailIntent);
        }
    }
}
 
開發者ID:dreaminglion,項目名稱:iosched-reader,代碼行數:26,代碼來源:BeamUtils.java

示例5: handleIntent

import android.content.Intent; //導入方法依賴的package包/類
private void handleIntent(final Intent intent) {
    final String action = intent.getAction();

    if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(action)) {
        final String inputType = intent.getType();
        final NdefMessage ndefMessage = (NdefMessage) intent
                .getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES)[0];
        final byte[] input = Nfc.extractMimePayload(Constants.MIMETYPE_TRANSACTION, ndefMessage);

        new BinaryInputParser(inputType, input) {
            @Override
            protected void handlePaymentIntent(final PaymentIntent paymentIntent) {
                cannotClassify(inputType);
            }

            @Override
            protected void error(final int messageResId, final Object... messageArgs) {
                dialog(WalletActivity.this, null, 0, messageResId, messageArgs);
            }
        }.parse();
    }
}
 
開發者ID:guodroid,項目名稱:okwallet,代碼行數:23,代碼來源:WalletActivity.java

示例6: processIntent

import android.content.Intent; //導入方法依賴的package包/類
private void processIntent(Intent i) {
    if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(i.getAction())) {
        Parcelable[] rawMsgs =
                i.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES);
        NdefMessage msg = (NdefMessage) rawMsgs[0];
        String url = new String(msg.getRecords()[0].getPayload());
        Utils.debugLog(TAG, "Got this URL: " + url);
        Toast.makeText(this, "Got this URL: " + url, Toast.LENGTH_LONG).show();
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
        intent.setClass(this, ManageReposActivity.class);
        startActivity(intent);
        finish();
    }
}
 
開發者ID:uhuru-mobile,項目名稱:mobile-store,代碼行數:15,代碼來源:RepoDetailsActivity.java

示例7: safeGetParcelableArrayExtra

import android.content.Intent; //導入方法依賴的package包/類
/**
 * Just like {@link Intent#getParcelableArrayExtra(String)} but doesn't throw exceptions.
 */
public static Parcelable[] safeGetParcelableArrayExtra(Intent intent, String name) {
    try {
        return intent.getParcelableArrayExtra(name);
    } catch (Throwable t) {
        Log.e(TAG, "getParcelableArrayExtra failed on intent " + intent);
        return null;
    }
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:12,代碼來源:IntentUtils.java

示例8: getValue

import android.content.Intent; //導入方法依賴的package包/類
/**
 * Get a value from an intent by a giving class and key.
 * @param intent
 *  the source intent
 * @param key
 *  the key of the value
 * @param clz
 *  the class of the value
 * @return
 *  the value from the source intent
 */
public static Object getValue(Intent intent, String key, Class<?> clz) {
    Object value = null;
    // Cause it is not an easy job to handle inheritance in apt, it is a lot easier to put the code in the Android environment.
    if(Bundle.class.isAssignableFrom(clz)) {
        // bundle implements parcelable, so it should place before parcelable.
        value = intent.getBundleExtra(key);
    } else if(Parcelable.class.isAssignableFrom(clz)) {
        value = intent.getParcelableExtra(key);
    } else if(Parcelable[].class.isAssignableFrom(clz)) {
        value = intent.getParcelableArrayExtra(key);
    } else if(boolean[].class.isAssignableFrom(clz)) {
        value = intent.getBooleanArrayExtra(key);
    } else if(byte[].class.isAssignableFrom(clz)) {
        value = intent.getByteArrayExtra(key);
    } else if(short[].class.isAssignableFrom(clz)) {
        value = intent.getShortArrayExtra(key);
    } else if(char[].class.isAssignableFrom(clz)) {
        value = intent.getCharArrayExtra(key);
    } else if(int[].class.isAssignableFrom(clz)) {
        value = intent.getIntArrayExtra(key);
    } else if(long[].class.isAssignableFrom(clz)) {
        value = intent.getLongArrayExtra(key);
    } else if(float[].class.isAssignableFrom(clz)) {
        value = intent.getFloatArrayExtra(key);
    } else if(double[].class.isAssignableFrom(clz)) {
        value = intent.getDoubleArrayExtra(key);
    } else if(String[].class.isAssignableFrom(clz)) {
        value = intent.getStringArrayExtra(key);
    } else if(CharSequence[].class.isAssignableFrom(clz)) {
        value = intent.getCharSequenceArrayExtra(key);
    } else if(Serializable.class.isAssignableFrom(clz)) {
        // some of the above are assignable for serializable, so serializable should be in the last place.
        value = intent.getSerializableExtra(key);
    } else {
        throw new RuntimeException(clz + " is not compatible with intent (key=" + key + ")");
    }

    return value;
}
 
開發者ID:foreveruseful,項目名稱:smartkey,代碼行數:51,代碼來源:IntentValueGetter.java

示例9: processIntent

import android.content.Intent; //導入方法依賴的package包/類
/**
 * Parses the NDEF Message from the intent and prints to the TextView
 */
void processIntent(Intent intent) {
    Parcelable[] rawMsgs = intent.getParcelableArrayExtra(
            NfcAdapter.EXTRA_NDEF_MESSAGES);
    // only one message sent during the beam
    NdefMessage msg = (NdefMessage) rawMsgs[0];
    // record 0 contains the MIME type, record 1 is the AAR, if present
    mInfoText.setText(new String(msg.getRecords()[0].getPayload()));
}
 
開發者ID:sdrausty,項目名稱:buildAPKsSamples,代碼行數:12,代碼來源:Beam.java

示例10: readNFCTag

import android.content.Intent; //導入方法依賴的package包/類
private String readNFCTag(Intent intent){
    String response=null;
    if(NfcAdapter.ACTION_NDEF_DISCOVERED.equals(intent.getAction())){
        //從標簽讀取數據
        Parcelable[] nfcMsgs=intent.getParcelableArrayExtra(
                NfcAdapter.EXTRA_NDEF_MESSAGES
        );
        NdefMessage msgs[]=null;
        int contentSize=0;
        if(nfcMsgs!=null){
            msgs=new NdefMessage[nfcMsgs.length];
            // 標簽可能存儲多個NdefMessage對象,一般情況下隻有一個
            for(int i=0;i<nfcMsgs.length;i++){
                // 轉換為NdefMessage對象
                msgs[i]= (NdefMessage) nfcMsgs[i];
                // 計算數據的總長度
                contentSize+=msgs[i].toByteArray().length;
            }
        }
        try{
            if(msgs!=null){
                // 隻讀第一個信息
                NdefRecord record=msgs[0].getRecords()[0];
                response=parseTextRecord(record);
                System.out.println(response);
            }
        }
        catch (Exception e){
            Toast.makeText(getApplicationContext(),e.getMessage(),Toast.LENGTH_LONG).show();
        }
    }
    return response;
}
 
開發者ID:Quick-Tip,項目名稱:Quick-Tip-Consumer,代碼行數:34,代碼來源:NFCReadActivity.java

示例11: onCreate

import android.content.Intent; //導入方法依賴的package包/類
@SuppressLint("MissingSuperCall")
@Override
protected void onCreate(Bundle savedInstanceState) {
    Intent intent = getIntent();
    int userId = intent.getIntExtra(Constants.EXTRA_USER_HANDLE, VUserHandle.getCallingUserId());
    mOptions = intent.getParcelableExtra(EXTRA_DATA);
    mResultWho = intent.getStringExtra(EXTRA_WHO);
    mRequestCode = intent.getIntExtra(EXTRA_REQUEST_CODE, 0);
    Parcelable targetParcelable = intent.getParcelableExtra(Intent.EXTRA_INTENT);
    if (!(targetParcelable instanceof Intent)) {
        VLog.w("ChooseActivity", "Target is not an intent: " + targetParcelable);
        finish();
        return;
    }
    Intent target = (Intent) targetParcelable;
    CharSequence title = intent.getCharSequenceExtra(Intent.EXTRA_TITLE);
    if (title == null) {
        title = getString(R.string.choose);
    }
    Parcelable[] pa = intent.getParcelableArrayExtra(Intent.EXTRA_INITIAL_INTENTS);
    Intent[] initialIntents = null;
    if (pa != null) {
        initialIntents = new Intent[pa.length];
        for (int i = 0; i < pa.length; i++) {
            if (!(pa[i] instanceof Intent)) {
                VLog.w("ChooseActivity", "Initial intent #" + i
                        + " not an Intent: " + pa[i]);
                finish();
                return;
            }
            initialIntents[i] = (Intent) pa[i];
        }
    }
    super.onCreate(savedInstanceState, target, title, initialIntents, null, false, userId);
}
 
開發者ID:7763sea,項目名稱:VirtualHook,代碼行數:36,代碼來源:ChooserActivity.java

示例12: resolveIntent

import android.content.Intent; //導入方法依賴的package包/類
private void resolveIntent(Intent intent) {
    String action = intent.getAction();
    if (NfcAdapter.ACTION_TAG_DISCOVERED.equals(action)
            || NfcAdapter.ACTION_TECH_DISCOVERED.equals(action)
            || NfcAdapter.ACTION_NDEF_DISCOVERED.equals(action)) {
        Parcelable[] rawMsgs = intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES);
        NdefMessage[] msgs;
        if (rawMsgs != null) {
            msgs = new NdefMessage[rawMsgs.length];
            for (int i = 0; i < rawMsgs.length; i++) {
                msgs[i] = (NdefMessage) rawMsgs[i];
            }
        } else {
            // Unknown tag type
            //byte[] empty = new byte[0];
            //byte[] id = intent.getByteArrayExtra(NfcAdapter.EXTRA_ID);
            Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
            showTagId(tag);
            //byte[] payload = dumpTagData(tag).getBytes();
            //NdefRecord record = new NdefRecord(NdefRecord.TNF_UNKNOWN, empty, id, payload);
            //NdefMessage msg = new NdefMessage(new NdefRecord[] { record });
            //msgs = new NdefMessage[] { msg };
        }
        // Setup the views
        //buildTagViews(msgs);
    }
}
 
開發者ID:rainhard,項目名稱:wNFCard,代碼行數:28,代碼來源:NewCardActivity.java

示例13: onCreate

import android.content.Intent; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    Intent intent = getIntent();
    int userId = intent.getIntExtra(Constants.EXTRA_USER_HANDLE, VUserHandle.getCallingUserId());
    mOptions = intent.getParcelableExtra(EXTRA_DATA);
    mResultWho = intent.getStringExtra(EXTRA_WHO);
    mRequestCode = intent.getIntExtra(EXTRA_REQUEST_CODE, 0);
    Parcelable targetParcelable = intent.getParcelableExtra(Intent.EXTRA_INTENT);
    if (!(targetParcelable instanceof Intent)) {
        VLog.w("ChooseActivity", "Target is not an intent: " + targetParcelable);
        finish();
        return;
    }
    Intent target = (Intent) targetParcelable;
    CharSequence title = intent.getCharSequenceExtra(Intent.EXTRA_TITLE);
    if (title == null) {
        title = getString(R.string.choose);
    }
    Parcelable[] pa = intent.getParcelableArrayExtra(Intent.EXTRA_INITIAL_INTENTS);
    Intent[] initialIntents = null;
    if (pa != null) {
        initialIntents = new Intent[pa.length];
        for (int i = 0; i < pa.length; i++) {
            if (!(pa[i] instanceof Intent)) {
                VLog.w("ChooseActivity", "Initial intent #" + i
                        + " not an Intent: " + pa[i]);
                finish();
                return;
            }
            initialIntents[i] = (Intent) pa[i];
        }
    }
    super.onCreate(savedInstanceState, target, title, initialIntents, null, false, userId);
}
 
開發者ID:codehz,項目名稱:container,代碼行數:35,代碼來源:ChooserActivity.java

示例14: onCreate

import android.content.Intent; //導入方法依賴的package包/類
@Override
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setRetainInstance(true);
    setHasOptionsMenu(true);

    bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();

    backgroundThread = new HandlerThread("backgroundThread", Process.THREAD_PRIORITY_BACKGROUND);
    backgroundThread.start();
    backgroundHandler = new Handler(backgroundThread.getLooper());

    if (savedInstanceState != null) {
        restoreInstanceState(savedInstanceState);
    } else {
        final Intent intent = activity.getIntent();
        final String action = intent.getAction();
        final Uri intentUri = intent.getData();
        final String scheme = intentUri != null ? intentUri.getScheme() : null;
        final String mimeType = intent.getType();

        if ((Intent.ACTION_VIEW.equals(action) || NfcAdapter.ACTION_NDEF_DISCOVERED.equals(action))
                && intentUri != null && "bitcoin".equals(scheme)) {
            initStateFromBitcoinUri(intentUri);
        } else if ((NfcAdapter.ACTION_NDEF_DISCOVERED.equals(action))
                && PaymentProtocol.MIMETYPE_PAYMENTREQUEST.equals(mimeType)) {
            final NdefMessage ndefMessage = (NdefMessage) intent
                    .getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES)[0];
            final byte[] ndefMessagePayload = Nfc.extractMimePayload(PaymentProtocol.MIMETYPE_PAYMENTREQUEST,
                    ndefMessage);
            initStateFromPaymentRequest(mimeType, ndefMessagePayload);
        } else if ((Intent.ACTION_VIEW.equals(action))
                && PaymentProtocol.MIMETYPE_PAYMENTREQUEST.equals(mimeType)) {
            final byte[] paymentRequest = BitcoinIntegration.paymentRequestFromIntent(intent);

            if (intentUri != null)
                initStateFromIntentUri(mimeType, intentUri);
            else if (paymentRequest != null)
                initStateFromPaymentRequest(mimeType, paymentRequest);
            else
                throw new IllegalArgumentException();
        } else if (intent.hasExtra(SendCoinsActivity.INTENT_EXTRA_PAYMENT_INTENT)) {
            initStateFromIntentExtras(intent.getExtras());
        } else {
            updateStateFrom(PaymentIntent.blank());
        }
    }
}
 
開發者ID:guodroid,項目名稱:okwallet,代碼行數:50,代碼來源:SendCoinsFragment.java

示例15: getFiles

import android.content.Intent; //導入方法依賴的package包/類
public static File_POJO[] getFiles(Intent workIntent) {
    Parcelable[] parcelables = workIntent.getParcelableArrayExtra(FILES);
    return File_POJO.generateArray(parcelables);
}
 
開發者ID:kollerlukas,項目名稱:Camera-Roll-Android-App,代碼行數:5,代碼來源:FileOperation.java


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