android.content.Intent.getParcelableArrayExtra()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(6.9k)|赞(0)|评价(0)|浏览(187)

本文整理了Java中android.content.Intent.getParcelableArrayExtra()方法的一些代码示例,展示了Intent.getParcelableArrayExtra()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Intent.getParcelableArrayExtra()方法的具体详情如下:
包路径:android.content.Intent
类名称:Intent
方法名:getParcelableArrayExtra

Intent.getParcelableArrayExtra介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

Intent intent = getIntent();
if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(intent.getAction())) {
  NdefMessage ndefMessage = null;
  Parcelable[] rawMessages = intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES);
  if ((rawMessages != null) && (rawMessages.length > 0)) {
    ndefMessage = (NdefMessage)rawMessages[0];
  }

  // TODO: do something with the received NDEF message
}

代码示例来源:origin: commonsguy/cw-omnibus

private void handleIntent(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());
  beamFragment.loadUrl(url);
 }
}

代码示例来源:origin: commonsguy/cw-omnibus

void readFromTag(Intent i) {
 Parcelable[] msgs=
   (Parcelable[])i.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES);
 if (msgs.length > 0) {
  NdefMessage msg=(NdefMessage)msgs[0];
  if (msg.getRecords().length > 0) {
   NdefRecord rec=msg.getRecords()[0];
   secretMessage.setText(new String(rec.getPayload(), US_ASCII));
  }
 }
}

代码示例来源:origin: android-hacker/VirtualXposed

title = getString(R.string.choose);
Parcelable[] pa = intent.getParcelableArrayExtra(Intent.EXTRA_INITIAL_INTENTS);
Intent[] initialIntents = null;
if (pa != null) {

代码示例来源:origin: robolectric/robolectric

@Test
public void testParcelableArrayExtra() throws Exception {
 Intent intent = new Intent();
 Parcelable parcelable = new TestParcelable(11);
 intent.putExtra("foo", parcelable);
 assertSame(null, intent.getParcelableArrayExtra("foo"));
 Parcelable[] parcelables = {new TestParcelable(12), new TestParcelable(13)};
 assertSame(intent, intent.putExtra("bar", parcelables));
 assertSame(parcelables, intent.getParcelableArrayExtra("bar"));
}

代码示例来源:origin: skjolber/ndef-tools-for-android

/**
 * {@link Intent} constructor. Extracts {@link NdefMessage} using key {@link NfcAdapter#EXTRA_NDEF_MESSAGES}.
 * 
 * @param intent intent containing NDEF data
 * @throws FormatException if known record type cannot be parsed
 */

public Message(Intent intent) throws FormatException {
  this(intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES));
}

代码示例来源:origin: stackoverflow.com

Intent i = getIntent();
Bitmap [] bitmaps = (Bitmap[]) i.getParcelableArrayExtra ("bitmaps");

代码示例来源:origin: stackoverflow.com

Intent intent = getIntent();
intent.getParcelableArrayExtra("key");

代码示例来源:origin: stackoverflow.com

Intent intent = getIntent();
 Parcelable[] parcelables = intent.getParcelableArrayExtra("ASD");

代码示例来源:origin: stackoverflow.com

public class NfcReceiver extends BroadcastReceiver {
  /* ... */

  @Override
  public void onReceive(Context context, Intent intent) {
    if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(getIntent().getAction())) {
      Parcelable[] rawMsgs =_
       intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES);
      if (rawMsgs != null) {
        msgs = new NdefMessage[rawMsgs.length];
        for (int i = 0; i < rawMsgs.length; i++) {
          msgs[i] = (NdefMessage) rawMsgs[i];
        }
      }
    } /* end handle NDEF_DISCOVERED */
  } /* end onReceive */
} /* end BroadcastReceiver*/

代码示例来源:origin: stackoverflow.com

public String getNfcData(Intent intent) {
 if (intent.hasExtra(NfcAdapter.EXTRA_TAG)) {
   Parcelable[] parcelables = intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES);
   if (parcelables != null && parcelables.length > 0) {
     String data = readTextFromMessage((NdefMessage) parcelables[0]);
     return data;
   } else {
     Toast.makeText(context, "Cannot Read From Tag.", Toast.LENGTH_LONG).show();
     return "No NDEF messages found!";
   }
 }
 return "";

代码示例来源:origin: stackoverflow.com

@Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.activity_daily_forecast);
   Intent intent = getIntent();
   Parcelable[] parcelables = intent.getParcelableArrayExtra(MainActivity.DAILY_FORECAST);
   mDays = Arrays.copyOf(parcelables, parcelables.length, Day[].class);
   DayAdapter adapter = new DayAdapter(this, mDays);
   setListAdapter(adapter);
 }

代码示例来源:origin: stackoverflow.com

private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
  public void onReceive(Context context, Intent intent) {
    //deviceExtra is our in range device
    deviceExtra  = 
    intent.getParcelableExtra("android.bluetooth.device.extra.DEVICE");
    Parcelable[] uuidExtra = 
    intent.getParcelableArrayExtra("android.bluetooth.device.extra.UUID");
}}};

代码示例来源:origin: stackoverflow.com

Intent intent=getIntent();
 NdefMessage[] msgs;
  if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(getIntent().getAction())) {
     Parcelable[] rawMsgs = intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES);
     NdefRecord relayRecord = ((NdefMessage)rawMsgs[0]).getRecords()[0];
     String nfcData = new String(relayRecord.getPayload());
     Toast.makeText(getApplicationContext(),nfcData,Toast.LENGTH_LONG).show();
   }

代码示例来源:origin: JackWHLiu/jackknife

public static Parcelable[] getParcelableArrayExtra(Intent intent, String name) {
  if (intent != null || !hasExtra(intent, name)) return null;
  return intent.getParcelableArrayExtra(name);
}

代码示例来源:origin: cbeyls/fosdem-companion-android

/**
   * Extracts application-specific data sent through NFC from an intent.
   * You must first ensure that the intent contains NFC data by calling hasAppData().
   *
   * @return The extracted app data as an NdefRecord
   */
  public static NdefRecord extractAppData(Intent intent) {
    Parcelable[] rawMsgs = intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES);
    NdefMessage msg = (NdefMessage) rawMsgs[0];
    return msg.getRecords()[0];
  }
}

代码示例来源:origin: stackoverflow.com

void parseNdefMessage(Intent intent) {
  Parcelable[] ndefMessageArray = intent.getParcelableArrayExtra(
      NfcAdapter.EXTRA_NDEF_MESSAGES);
  NdefMessage ndefMessage = (NdefMessage) ndefMessageArray[0];
  String msg = new String(ndefMessage.getRecords()[0].getPayload());
  Toast.makeText(this, msg, Toast.LENGTH_LONG).show();
  Toast.makeText( getApplicationContext(),"Here is my text", 
    Toast.LENGTH_LONG).show();

  //editText = (EditText) findViewById(R.id.editText);
  //String text = editText.getText().toString();
  editText.setText(msg); //my attempt to set my received data to "editText" field
}

代码示例来源:origin: stackoverflow.com

Intent intent = getIntent();

Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
String myTagId = bytesToHexString(tag.getId());

Parcelable[] rawMsgs = intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES);
NdefMessage[] msgs = new NdefMessage[rawMsgs.length];

NdefRecord[] records = msgs[i].getRecords();

byte[] payload = records[j].getPayload();

代码示例来源:origin: kollerlukas/Camera-Roll-Android-App

public static File_POJO[] getFiles(Intent workIntent) {
  Parcelable[] parcelables = workIntent.getParcelableArrayExtra(FILES);
  return File_POJO.generateArray(parcelables);
}

代码示例来源:origin: xiaolongonly/Ticket-Analysis

public static Parcelable[] getParcelableArrayExtra(Intent intent, String name) {
  if (!hasIntent(intent) || !hasExtra(intent, name)) return null;
  return intent.getParcelableArrayExtra(name);
}

相关文章

Intent类方法