Example usage for android.content Intent getParcelableArrayListExtra

List of usage examples for android.content Intent getParcelableArrayListExtra

Introduction

In this page you can find the example usage for android.content Intent getParcelableArrayListExtra.

Prototype

public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) 

Source Link

Document

Retrieve extended data from the intent.

Usage

From source file:org.camlistore.UploadService.java

private void handleSendMultiple(Intent intent) {
    ArrayList<Parcelable> items = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM);
    ArrayList<Uri> uris = new ArrayList<Uri>(items.size());
    for (Parcelable p : items) {
        if (!(p instanceof Uri)) {
            Log.d(TAG, "uh, unknown thing " + p);
            continue;
        }//  w  ww .  ja  va 2 s  .c o m
        uris.add((Uri) p);
    }
    final ArrayList<Uri> finalUris = uris;
    Util.runAsync(new Runnable() {
        @Override
        public void run() {
            try {
                service.enqueueUploadList(finalUris);
            } catch (RemoteException e) {
            }
        }
    });
}

From source file:de.enlightened.peris.PerisMain.java

final void handleSendMultipleImages(final Intent intent) {
    final ArrayList<Uri> imageUris = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM);
    /*//from   w ww  . j a v  a  2s  . c o  m
    if (imageUris != null) {
      // Update UI to reflect multiple images being shared
    }*/
}

From source file:com.perm.DoomPlay.FullPlaybackActivity.java

void getTracks(Intent intent) {
    if (intent.getAction().equals(Intent.ACTION_VIEW)) {
        String path = intent.getData().getPath();
        File fpath = new File(path);

        if (PlaylistParser.isFileCue(path)) {
            audios = PlaylistParser.displayCue(fpath, this);
        } else if (PlaylistParser.isFilePlaylist(path)) {
            audios = PlaylistParser.displayPlaylist(fpath, this);
        } else {/*from w ww .j  ava 2 s  . co m*/
            audios = new ArrayList<Audio>();
            audios.add(getAudioFromPath(fpath));
        }
    } else if (intent.getAction().equals(actionPlayFull) || intent.getAction().equals(actionReturnFull)) {
        audios = intent.getParcelableArrayListExtra((FileSystemActivity.keyMusic));
    } else {
        audios = playingService.audios;
    }

    if (intent.getIntExtra(keyIndex, 11116) != 11116)
        intentService.putExtra(keyIndex, intent.getIntExtra(keyIndex, 0));
}

From source file:com.dycode.jepretstory.mediachooser.activity.BucketHomeFragmentActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    super.onActivityResult(requestCode, resultCode, data);

    if (resultCode == Activity.RESULT_OK) {

        if (requestCode == MediaChooserConstants.BUCKET_SELECT_IMAGE_CODE) {
            //reset
            //addMedia(mSelectedImage, data.getStringArrayListExtra("list"));
            addMediaModel(mSelectedImages, data.getParcelableArrayListExtra("selectedImages"));

            if (mImageFragment != null) {
                mImageFragment.setCurrentSelectedImages(mSelectedImages);
            }//from w ww .  j ava  2  s.c  om

            onImageSelectedCount(mSelectedImages.size());

        } else if (requestCode == MediaChooserConstants.BUCKET_SELECT_VIDEO_CODE) {
            //reset
            //addMedia(mSelectedVideo, data.getStringArrayListExtra("list"));
            addMediaModel(mSelectedVideos, data.getParcelableArrayListExtra("selectedVideos"));

            if (mVideoFragment != null) {
                mVideoFragment.setCurrentSelectedVideos(mSelectedVideos);
            }

            onVideoSelectedCount(mSelectedVideos.size());

        } else if (requestCode == MediaChooserConstants.CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE) {

            sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, fileUri));

            final AlertDialog alertDialog = MediaChooserConstants.getDialog(BucketHomeFragmentActivity.this)
                    .create();
            alertDialog.show();

            handler.postDelayed(new Runnable() {
                @Override
                public void run() {
                    // Do something after 2000ms
                    String fileUriString = fileUri.toString().replaceFirst("file:///", "/").trim();

                    if (mImageFragment != null) {
                        mImageFragment.getAdapter().addLatestEntry(fileUriString);
                        mImageFragment.getAdapter().notifyDataSetChanged();
                    }
                    alertDialog.dismiss();
                }
            }, 5000);

        } else if (requestCode == MediaChooserConstants.CAPTURE_VIDEO_ACTIVITY_REQUEST_CODE) {

            sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, fileUri));

            final AlertDialog alertDialog = MediaChooserConstants.getDialog(BucketHomeFragmentActivity.this)
                    .create();
            alertDialog.show();
            handler.postDelayed(new Runnable() {
                @Override
                public void run() {
                    // Do something after 2000ms
                    String fileUriString = fileUri.toString().replaceFirst("file:///", "/").trim();

                    if (mVideoFragment != null) {
                        mVideoFragment.getAdapter().addLatestEntry(fileUriString);
                        mVideoFragment.getAdapter().notifyDataSetChanged();
                    }

                    //add to mediastore
                    //addVideoToMediaStore(fileUri);

                    alertDialog.dismiss();
                }
            }, 5000);
        }
    }
}

From source file:com.krayzk9s.imgurholo.activities.ImgurLinkActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    destroyed = false;/*from   w  ww  .  j av  a 2 s.c  om*/
    if (getActionBar() != null)
        getActionBar().setDisplayHomeAsUpEnabled(true);
    Intent intent = getIntent();
    String action = intent.getAction();
    String type = intent.getType();
    Log.d("New Intent", intent.toString());
    if (Intent.ACTION_SEND.equals(action) && type != null) {
        if (type.startsWith("image/")) {
            Toast.makeText(this, R.string.toast_uploading, Toast.LENGTH_SHORT).show();
            Intent serviceIntent = new Intent(this, UploadService.class);
            if (intent.getExtras() == null)
                finish();
            serviceIntent.setData((Uri) intent.getExtras().get("android.intent.extra.STREAM"));
            startService(serviceIntent);
            finish();
        }
    } else if (Intent.ACTION_SEND_MULTIPLE.equals(action)) {
        Log.d("sending", "sending multiple");
        Toast.makeText(this, R.string.toast_uploading, Toast.LENGTH_SHORT).show();
        ArrayList<Parcelable> list = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM);
        Intent serviceIntent = new Intent(this, UploadService.class);
        serviceIntent.putParcelableArrayListExtra("images", list);
        startService(serviceIntent);
        finish();
    } else if (Intent.ACTION_VIEW.equals(action) && intent.getData() != null
            && intent.getData().toString().startsWith("http://imgur.com/a")) {
        String uri = intent.getData().toString();
        album = uri.split("/")[4];
        Log.d("album", album);
        Fetcher fetcher = new Fetcher(this, "/3/album/" + album, ApiCall.GET, null, apiCall, ALBUM);
        fetcher.execute();
    } else if (Intent.ACTION_VIEW.equals(action)
            && intent.getData().toString().startsWith("http://imgur.com/gallery/")) {
        String uri = intent.getData().toString();
        final String album = uri.split("/")[4];
        if (album.length() == 5) {
            Log.d("album", album);
            Fetcher fetcher = new Fetcher(this, "/3/album/" + album, ApiCall.GET, null, apiCall, ALBUM);
            fetcher.execute();
        } else if (album.length() == 7) {
            Log.d("image", album);
            Fetcher fetcher = new Fetcher(this, "/3/gallery/image/" + album, ApiCall.GET, null, apiCall, IMAGE);
            fetcher.execute();
        }
    } else if (Intent.ACTION_VIEW.equals(action) && intent.getData().toString().startsWith("http://i.imgur")) {
        String uri = intent.getData().toString();
        final String image = uri.split("/")[3].split("\\.")[0];
        Log.d("image", image);
        Fetcher fetcher = new Fetcher(this, "/3/image/" + image, ApiCall.GET, null, apiCall, IMAGE);
        fetcher.execute();
    }
}

From source file:org.exoplatform.shareextension.ShareActivity.java

@Override
protected void onCreate(Bundle bundle) {
    super.onCreate(bundle);

    setContentView(R.layout.share_extension_activity);

    loadingIndicator = (ProgressBar) findViewById(R.id.share_progress_indicator);
    mainButton = (Button) findViewById(R.id.share_button);
    mainButton.setTag(R.attr.share_button_type_post);
    online = false;//from  w  w  w. j  a  va2s  . c  o m
    postInfo = new SocialPostInfo();

    if (isIntentCorrect()) {
        Intent intent = getIntent();
        String type = intent.getType();
        if ("text/plain".equals(type)) {
            // The share does not contain an attachment
            // TODO extract the link info - MOB-1866
            postInfo.postMessage = intent.getStringExtra(Intent.EXTRA_TEXT);
        } else {
            // The share contains an attachment
            if (mMultiFlag) {
                mAttachmentUris = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM);
            } else {
                Uri contentUri = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM);
                if (contentUri != null) {
                    mAttachmentUris = new ArrayList<Uri>();
                    mAttachmentUris.add(contentUri);
                }
                if (Log.LOGD) {
                    Log.d(LOG_TAG, "Number of files to share: ", mAttachmentUris.size());
                }
            }
            prepareAttachmentsAsync();
        }

        init();

        // Create and display the composer, aka ComposeFragment
        ComposeFragment composer = ComposeFragment.getFragment();
        openFragment(composer, ComposeFragment.COMPOSE_FRAGMENT, Anim.NO_ANIM);
    } else {
        // We're not supposed to reach this activity by anything else than an
        // ACTION_SEND intent
        finish();
    }

}

From source file:com.shearosario.tothepathandback.ClosestStationsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_closest_stations);

    getActionBar().setDisplayHomeAsUpEnabled(true);

    Intent intent = getIntent();
    context = this;
    activity = this;

    adView = (AdView) this.findViewById(R.id.adViewClosest);
    AdRequest adRequest = new AdRequest.Builder().addTestDevice("949F5429A9EC251C1DD4395558D33531").build();
    // AdRequest adRequest = new AdRequest.Builder().build();
    adView.loadAd(adRequest);/*from   www  .  j  av a  2  s. co  m*/

    if (intent.hasExtra("Manual")) {
        double[] manual = intent.getDoubleArrayExtra("Manual");
        origin = new LatLng(manual[0], manual[1]);
    } else if (intent.hasExtra("Current")) {
        double[] current = intent.getDoubleArrayExtra("Current");
        origin = new LatLng(current[0], current[1]);
    }

    double[] entranceMeasures = intent.getDoubleArrayExtra("closestSortMeasures");
    ArrayList<Entrance> closestEntrances = intent.getParcelableArrayListExtra("closestEntrances");

    MySimpleArrayAdapter adapter = new MySimpleArrayAdapter(this, R.layout.listitem, closestEntrances,
            entranceMeasures);
    //ListAdapter adapter = createListAdapter(allStationsSortDistance);
    ListView listview = (ListView) findViewById(R.id.ClosestStationsList);
    listview.setAdapter(adapter);
    //setListAdapter(adapter);

    final GoogleMap gMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.mapview)).getMap();
    gMap.setMyLocationEnabled(false);
    gMap.addMarker(new MarkerOptions().title("Origin").position(origin));
    gMap.moveCamera(CameraUpdateFactory.newLatLngZoom(origin, 13));
    gMap.setBuildingsEnabled(false);
    gMap.getUiSettings().setZoomControlsEnabled(false);

    TextView textView = (TextView) findViewById(R.id.osm_directions);
    textView.setText(Html.fromHtml("Data provided by  OpenStreetMap contributors "
            + "<a href=\"http://www.openstreetmap.org/copyright\">License</a>"));
    textView.setMovementMethod(LinkMovementMethod.getInstance());

    textView = (TextView) findViewById(R.id.directions_text);
    textView.setText(Html.fromHtml(
            "Directions, Nominatim Search Courtesy of " + "<a href=\"http://www.mapquest.com\">MapQuest</a>"));
    textView.setMovementMethod(LinkMovementMethod.getInstance());

    listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            final Entrance item = (Entrance) parent.getItemAtPosition(position);

            gMap.clear();

            LatLngBounds bounds = new LatLngBounds.Builder().include(origin)
                    .include(new LatLng(item.getEntranceLocation()[0], item.getEntranceLocation()[1])).build();

            gMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 150));

            gMap.addMarker(new MarkerOptions().title("Origin").position(origin));

            String stationName = null;
            for (int i = 0; i < MainActivity.getAllStations().size(); i++) {
                if (item.getStopid().equalsIgnoreCase(MainActivity.getAllStations().get(i).getStopID())) {
                    stationName = MainActivity.getAllStations().get(i).getStopName();
                    break;
                }
            }

            gMap.addMarker(new MarkerOptions()
                    // .title(item.getStationName())
                    .title(stationName)
                    .position(new LatLng(item.getEntranceLocation()[0], item.getEntranceLocation()[1])));

            Button button = (Button) findViewById(R.id.button_destination);
            button.setEnabled(true);
            // button.setText("Select " + item.getStationName());
            button.setText("Select " + stationName);

            button.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    /*
                     * To check if the phone is currently using a network connection. 
                     * Listens to broadcasts when the the device is or is not connected to 
                     * a network
                     */
                    ConnectivityManager cm = (ConnectivityManager) context
                            .getSystemService(Context.CONNECTIVITY_SERVICE);
                    NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
                    boolean isConnected = activeNetwork != null && activeNetwork.isConnectedOrConnecting();
                    if (!isConnected) {
                        Toast.makeText(context, "No network connection", Toast.LENGTH_SHORT).show();
                        return;
                    }

                    new DisplayDirectionsIntent(context, activity, origin, item);
                }
            });
        }
    });
}

From source file:com.monkey.entonado.MainActivity.java

/**
 * Recibe el resultado de intentar escanear un codigo QR
 */// w  w  w  . ja v a 2 s .  c  om
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == 0) {
        if (resultCode == RESULT_OK) {
            ip = data.getStringExtra("SCAN_RESULT");

            Conectar conectar = new Conectar(this);
            conectar.start();

        } else if (resultCode == RESULT_CANCELED) {

            if (canal == null) {
                mensajeConexion = "No te conectaste";
                intentoConectar = true;
            }
        }
    } else if (requestCode == 999) {
        if (resultCode == RESULT_OK) {
            milista = data.getParcelableArrayListExtra("LISTA_ACTUALIZADA");
        } else if (resultCode == RESULT_BOTON) {
            milista = data.getParcelableArrayListExtra("LISTA_ACTUALIZADA");

            if (canal != null && canal.isConnected() && mensajeConexion != null
                    && !mensajeConexion.equals("desconectado")) {
                ThreadEnviarLista enviar = new ThreadEnviarLista(this);
                enviar.start();

                while (enviar.isAlive()) {

                }
                mostrarMensaje(mensajeConexion);
            }

            intentoEnviarLista = true;

        } else if (resultCode == RESULT_CANCELED) {
            System.out.println("Lista actualizada : cancel");
        }
    }
}

From source file:com.android.tv.settings.users.AppRestrictionsFragment.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    AppRestrictionsPreference pref = (AppRestrictionsPreference) findPreference(
            mCustomRequestMap.get(requestCode));
    if (pref == null) {
        Log.w(TAG, "Unknown requestCode " + requestCode);
        return;/*from ww w . j  a  va  2  s  . c  o  m*/
    }

    if (resultCode == Activity.RESULT_OK) {
        String packageName = getPackageFromKey(pref.getKey());
        ArrayList<RestrictionEntry> list = data.getParcelableArrayListExtra(Intent.EXTRA_RESTRICTIONS_LIST);
        Bundle bundle = data.getBundleExtra(Intent.EXTRA_RESTRICTIONS_BUNDLE);
        if (list != null) {
            // If there's a valid result, persist it to the user manager.
            pref.setRestrictions(list);
            mUserManager.setApplicationRestrictions(packageName,
                    RestrictionsManager.convertRestrictionsToBundle(list), mUser);
        } else if (bundle != null) {
            // If there's a valid result, persist it to the user manager.
            mUserManager.setApplicationRestrictions(packageName, bundle, mUser);
        }
    }
    // Remove request from the map
    mCustomRequestMap.remove(requestCode);
}

From source file:org.sufficientlysecure.keychain.ui.EncryptFileActivity.java

/**
 * Handles all actions with this intent//from  w w w .jav a2  s . com
 *
 * @param intent
 */
private void handleActions(Intent intent) {
    String action = intent.getAction();
    Bundle extras = intent.getExtras();
    String type = intent.getType();
    ArrayList<Uri> uris = new ArrayList<Uri>();

    if (extras == null) {
        extras = new Bundle();
    }

    if (intent.getData() != null) {
        uris.add(intent.getData());
    }

    /*
     * Android's Action
     */

    // When sending to OpenKeychain Encrypt via share menu
    if (Intent.ACTION_SEND.equals(action) && type != null) {
        // Files via content provider, override uri and action
        uris.clear();
        uris.add(intent.<Uri>getParcelableExtra(Intent.EXTRA_STREAM));
    }

    if (Intent.ACTION_SEND_MULTIPLE.equals(action) && type != null) {
        uris = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM);
    }

    if (extras.containsKey(EXTRA_ASCII_ARMOR)) {
        mUseArmor = extras.getBoolean(EXTRA_ASCII_ARMOR, true);
    }

    // preselect keys given by intent
    mSigningKeyId = extras.getLong(EXTRA_SIGNATURE_KEY_ID);
    mEncryptionKeyIds = extras.getLongArray(EXTRA_ENCRYPTION_KEY_IDS);

    // Save uris
    mInputUris = uris;

}