List of usage examples for android.content Intent getParcelableArrayExtra
public Parcelable[] getParcelableArrayExtra(String name)
From source file:Main.java
public static Parcelable[] getParcelableArrayExtra(Intent intent, String name) { if (!hasIntent(intent) || !hasExtra(intent, name)) return null; return intent.getParcelableArrayExtra(name); }
From source file:org.chromium.chrome.browser.util.IntentUtils.java
/** * Just like {@link Intent#getParcelableArrayExtra(String)} but doesn't throw exceptions. *///from w w w. j a va2 s . c o m 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; } }
From source file:info.shibafu528.gallerymultipicker.MultiPickerActivity.java
public static Uri[] getPickedUris(Intent onActivityResultData) { Parcelable[] uris = onActivityResultData.getParcelableArrayExtra(EXTRA_URIS); Uri[] pickedUris = new Uri[uris.length]; for (int i = 0; i < uris.length; i++) { pickedUris[i] = (Uri) uris[i];/*from ww w .j a v a2 s . c om*/ } return pickedUris; }
From source file:org.akop.crosswords.service.CrosswordFetchService.java
@Override protected void onHandleIntent(Intent intent) { Parcelable[] parcelables = intent.getParcelableArrayExtra("requests"); boolean writeToStorage = intent.getBooleanExtra("writeToStorage", false); boolean broadcastResults = intent.getBooleanExtra("broadcastResults", false); Storage storage = Storage.getInstance(); CrosswordFetchRunnable.Request[] requests = new CrosswordFetchRunnable.Request[parcelables.length]; System.arraycopy(parcelables, 0, requests, 0, parcelables.length); CrosswordFetchRunnable.Result[] resultArray = new CrosswordFetchRunnable.Result[requests.length]; List<CrosswordFetchRunnable.Result> successes = new ArrayList<>(); List<CrosswordFetchRunnable.Result> failures = new ArrayList<>(); for (int i = 0, n = requests.length; i < n; i++) { CrosswordFetchRunnable f = new CrosswordFetchRunnable(requests[i]); f.run();/* w w w . j av a 2 s . c o m*/ CrosswordFetchRunnable.Result result = f.getResult(); if (result.success()) { if (writeToStorage) { storage.write(Storage.FOLDER_INBOX, result.getCrossword()); } successes.add(result); } else { failures.add(result); } resultArray[i] = result; } if (broadcastResults) { Intent outgoing = new Intent(ACTION_FETCH_COMPLETE); outgoing.putExtra(INTENT_RESULTS, resultArray); LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(this); lbm.sendBroadcast(outgoing); } if (failures.size() < 1) { notifySuccesses(successes); } else { notifyFailures(failures); } }
From source file:com.commonsware.android.webbeam.WebBeamActivity.java
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);// w w w . j a v a 2 s . c o m } }
From source file:com.conferenceengineer.android.iosched.ui.TaskStackBuilderProxyActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); TaskStackBuilder builder = TaskStackBuilder.create(this); Intent proxyIntent = getIntent(); if (!proxyIntent.hasExtra(EXTRA_INTENTS)) { finish();/* ww w .ja va 2 s .c om*/ return; } for (Parcelable parcelable : proxyIntent.getParcelableArrayExtra(EXTRA_INTENTS)) { builder.addNextIntent((Intent) parcelable); } builder.startActivities(); finish(); }
From source file:de.gadc.moneybeam.ReceiveRequestActivity.java
/** * Parses the NDEF Message from the {@link Intent} and sets the * {@link TextView}'s text.// w w w . j av a2 s .c o m */ private void processIntent(Intent intent) { final Parcelable[] rawMsgs = intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES); final NdefMessage msg = (NdefMessage) rawMsgs[0]; try { final JSONObject object = new JSONObject(new String(msg.getRecords()[0].getPayload())); email = object.getString(Configuration.PREF_MAIL); currency = object.getString(Configuration.CURRENCY); money = object.getString(Configuration.DOLLAR) + "." + object.getString(Configuration.CENTS); final String moneyString = object.getString(Configuration.DOLLAR) + "," + object.getString(Configuration.CENTS) + " " + object.getString(Configuration.CURRENCY); requestView.setText(getString(R.string.xy_wants_z_dollar_from_you, email, moneyString)); } catch (JSONException e) { e.printStackTrace(); } }
From source file:com.battlelancer.seriesguide.ui.AddActivity.java
/** * Parses the NDEF Message from the intent and prints to the TextView *///from w ww . ja v a 2s. c om @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) void processIntent(Intent intent) { Parcelable[] rawMsgs = intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES); // only one message sent during the beam NdefMessage msg = (NdefMessage) rawMsgs[0]; SearchResult show = new SearchResult(); show.tvdbid = Integer.valueOf(new String(msg.getRecords()[0].getPayload())); show.title = new String(msg.getRecords()[1].getPayload()); show.overview = new String(msg.getRecords()[2].getPayload()); // display add dialog AddShowDialogFragment.showAddDialog(show, getSupportFragmentManager()); }
From source file:io.v.example.vbeam.vbeamexample.MainActivity.java
@Override protected void onResume() { super.onResume(); Intent intent = getIntent(); if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(intent.getAction())) { Parcelable[] rawMsgs = intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES); if (rawMsgs != null) { for (int i = 0; i < rawMsgs.length; i++) { for (NdefRecord r : ((NdefMessage) rawMsgs[i]).getRecords()) { System.out.println("record " + r.toString() + "(" + r.toUri() + ")"); }/*from www . j a v a2s.c o m*/ } } } }
From source file:io.v.android.impl.google.services.beam.BeamActivity.java
@Override public void onResume() { super.onResume(); NdefMessage msgs[] = null;//from w w w .j ava 2 s . c o m Intent intent = getIntent(); if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(intent.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]; } } } if (msgs == null) { Log.d(TAG, "No ndef messages"); finish(); return; } VBeamManager.Data data = null; for (NdefMessage m : msgs) { data = VBeamManager.decodeMessage(m); if (data != null) break; } if (data == null) { Log.w(TAG, "Unable to deserialize data"); finish(); return; } Log.d(TAG, "connecting to " + data.name); VContext ctx = V.init(this).withTimeout(Duration.standardSeconds(2)); Options opts = new Options(); opts.set(OptionDefs.SERVER_AUTHORIZER, VSecurity.newPublicKeyAuthorizer(data.key)); IntentBeamerClient client = IntentBeamerClientFactory.getIntentBeamerClient(data.name); ListenableFuture<IntentBeamerClient.GetIntentOut> out = client.getIntent(ctx, data.secret, opts); Futures.addCallback(out, new FutureCallback<IntentBeamerClient.GetIntentOut>() { @Override public void onSuccess(IntentBeamerClient.GetIntentOut result) { try { Log.d(TAG, "got intent " + result.intentUri); int flags = 0; if (result.intentUri.startsWith("intent:")) { flags = Intent.URI_INTENT_SCHEME; } else { flags = Intent.URI_ANDROID_APP_SCHEME; } Intent resultIntent = Intent.parseUri(result.intentUri, flags); resultIntent.putExtra(VBeamManager.EXTRA_VBEAM_PAYLOAD, result.payload); startActivity(resultIntent); finish(); } catch (Throwable t) { t.printStackTrace(); } } @Override public void onFailure(Throwable t) { t.printStackTrace(); finish(); } }); }