当前位置: 首页>>代码示例>>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;未经允许,请勿转载。