List of usage examples for android.content Intent getStringArrayListExtra
public ArrayList<String> getStringArrayListExtra(String name)
From source file:com.seregil13.literarytracker.lightnovel.LightNovelEditFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == LiteraryTrackerUtils.GENRE_REQUEST_CODE) { Log.d(TAG, "Received result from Activity with code " + requestCode); if (resultCode == LiteraryTrackerUtils.GENRE_SUCCESS_CODE) { /* Updates the stored genres to be the selection returned from the Genre Selection Activity */ this.mGenres = data.getStringArrayListExtra(JsonKeys.GENRES.toString()); }//from w w w. ja v a 2 s .c o m } super.onActivityResult(requestCode, resultCode, data); }
From source file:io.jawg.osmcontributor.service.OfflineRegionDownloadService.java
private void startDownloadIfNeeded(Intent intent, final List<OfflineRegion> presentOfflineRegions) { if (intent == null) { return;//from w w w . j a v a 2s .c om } final int size = intent.getIntExtra(SIZE_PARAM, -1); if (size != -1) { int c = 0; // There is some regions to download for (int i = 0; i < size; i++) { ArrayList<String> areasString = intent.getStringArrayListExtra(LIST_PARAM + i); LatLngBounds bounds = convertToLatLngBounds(areasString); OfflineRegion presentOfflineRegion = containsInOfflineRegion(presentOfflineRegions, bounds); if (presentOfflineRegion == null) { // The region has never been downloaded String regionName = intent.getStringExtra(REGION_NAME_PARAM); regionName = regionName == null ? "Region " + (presentOfflineRegions.size() + c) : regionName; c++; downloadOfflineRegion(bounds, regionName); } else { //The region is already downloaded, we check if it was completed checkIfRegionDownloadIsCompleted(presentOfflineRegion); } } } }
From source file:com.learnncode.mediachooser.activity.HomeScreenMediaChooser.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) { addMedia(mSelectedImage, data.getStringArrayListExtra("list")); } else if (requestCode == MediaChooserConstants.BUCKET_SELECT_VIDEO_CODE) { addMedia(mSelectedVideo, data.getStringArrayListExtra("list")); } else if (requestCode == MediaChooserConstants.CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE) { sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, fileUri)); final AlertDialog alertDialog = MediaChooserConstants.getDialog(mContext).create(); alertDialog.show();//from w w w .java 2s .c o m handler.postDelayed(new Runnable() { @Override public void run() { //Do something after 2000ms String fileUriString = fileUri.toString().replaceFirst("file:///", "/").trim(); Fragment fragment = mViewPagerAdapter.getItem(0); if (fragment instanceof ImageFragment) { ImageFragment imageFragment = (ImageFragment) fragment; if (imageFragment != null) { imageFragment.addNewEntry(fileUriString); } } else { ImageFragment imageFragment = (ImageFragment) mViewPagerAdapter.getItem(1); if (imageFragment != null) { imageFragment.addNewEntry(fileUriString); } } 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(mContext).create(); alertDialog.show(); handler.postDelayed(new Runnable() { @Override public void run() { //Do something after 2000ms String fileUriString = fileUri.toString().replaceFirst("file:///", "/").trim(); Fragment fragment = mViewPagerAdapter.getItem(0); if (fragment instanceof VideoFragment) { VideoFragment videoFragment = (VideoFragment) fragment; if (videoFragment != null) { videoFragment.addNewEntry(fileUriString); } } else { VideoFragment videoFragment = (VideoFragment) mViewPagerAdapter.getItem(1); if (videoFragment != null) { videoFragment.addNewEntry(fileUriString); } } alertDialog.dismiss(); } }, 5000); } } }
From source file:de.j4velin.chess.Main.java
@Override public void onActivityResult(int request, int response, final Intent data) { super.onActivityResult(request, response, data); if (BuildConfig.DEBUG) Logger.log("Main onActivityResult"); if (response != Activity.RESULT_OK) { // user canceled return;/*from ww w. j a va 2 s . c o m*/ } if (request == RC_SELECT_PLAYERS) { // get the invitee list final ArrayList<String> invitees = data.getStringArrayListExtra(Games.EXTRA_PLAYER_IDS); // get auto-match criteria Bundle autoMatchCriteria; int minAutoMatchPlayers = data.getIntExtra(Multiplayer.EXTRA_MIN_AUTOMATCH_PLAYERS, 0); int maxAutoMatchPlayers = data.getIntExtra(Multiplayer.EXTRA_MAX_AUTOMATCH_PLAYERS, 0); if (minAutoMatchPlayers > 0) { autoMatchCriteria = RoomConfig.createAutoMatchCriteria(minAutoMatchPlayers, maxAutoMatchPlayers, 0); } else { autoMatchCriteria = null; } TurnBasedMatchConfig tbmc = TurnBasedMatchConfig.builder().addInvitedPlayers(invitees) .setAutoMatchCriteria(autoMatchCriteria).setVariant(StartFragment.LAST_SELECTED_MATCH_MODE) .build(); // kick the match off Games.TurnBasedMultiplayer.createMatch(mGoogleApiClient, tbmc) .setResultCallback(new ResultCallback<TurnBasedMultiplayer.InitiateMatchResult>() { @Override public void onResult(final TurnBasedMultiplayer.InitiateMatchResult result) { if (BuildConfig.DEBUG) Logger.log("InitiateMatchResult onResult " + result.getStatus()); // Check if the status code is not success; if (result.getStatus().getStatusCode() != GamesStatusCodes.STATUS_OK) { return; } TurnBasedMatch match = result.getMatch(); if (match.getData() == null) { Game.newGame(match, mGoogleApiClient); } else { if (!Game.load(match.getData(), match, mGoogleApiClient)) { updateApp(); return; } } startGame(match.getMatchId()); } }); } else if (request == RC_RESOLVE) { // We're coming back from an activity that was launched to resolve a // connection problem. For example, the sign-in UI. if (response == Activity.RESULT_OK && !mGoogleApiClient.isConnected() && !mGoogleApiClient.isConnecting()) { // Ready to try to connect again. mGoogleApiClient.connect(); } else if (response == GamesActivityResultCodes.RESULT_RECONNECT_REQUIRED && !mGoogleApiClient.isConnected() && !mGoogleApiClient.isConnecting()) { mGoogleApiClient.connect(); } else if (response == Activity.RESULT_CANCELED) { // User cancelled. mGoogleApiClient.disconnect(); } } }
From source file:com.example.castCambot.MainActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == REQUEST_CODE && resultCode == RESULT_OK) { ArrayList<String> matches = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS); if (matches.size() > 0) { Log.d(TAG, matches.get(0));// w ww. ja v a 2 s. c o m //sendMessage(matches.get(0)); Context context = getApplicationContext(); int duration = Toast.LENGTH_SHORT; String text = matches.get(0); Toast toast = Toast.makeText(context, text, duration); toast.show(); String goForward = "forward"; String turnLeft = "left"; String turnRight = "right"; String goBackwards = "backward"; if (text.contains(goForward)) { myHttpPost("go_forward"); mySleep(1000); myHttpPost("stop"); } if (text.contains(turnLeft)) { myHttpPost("turn_left"); mySleep(500); myHttpPost("stop"); } if (text.contains(turnRight)) { myHttpPost("turn_right"); mySleep(500); myHttpPost("stop"); } if (text.contains(goBackwards)) { myHttpPost("go_backward"); mySleep(1000); myHttpPost("stop"); } //auto trigger voiceButton on click //Button voiceButton = (Button) findViewById(R.id.voiceButton); //voiceButton.performClick(); } } super.onActivityResult(requestCode, resultCode, data); }
From source file:com.theultimatelabs.scale.ScaleActivity.java
protected void onActivityResult(int requestCode, int resultCode, Intent data) { Log.v(TAG, "GOT SPEECH RESULT " + resultCode + " req: " + requestCode); if (resultCode == RESULT_OK) { ArrayList<String> matches = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS); Log.i(TAG, "Check for density"); StringBuilder densityName = new StringBuilder(); double density = findMatch(matches, mDensitiesJson, densityName); Log.i(TAG, "Check for volume"); StringBuilder volumeName = new StringBuilder(); double volume = findMatch(matches, mVolumesJson, volumeName); Log.i(TAG, "Check for weight"); StringBuilder weightName = new StringBuilder(); double weight = findMatch(matches, mWeightsJson, weightName); if (density != 0 && volume != 0) { mUnitsRatio = 1000.0 / density / volume; mUnitsText = String.format("%s of %s", volumeName, densityName); } else if (weight != 0) { mUnitsRatio = 1.0 / weight;//from www . j a v a 2 s . c o m mUnitsText = String.format("%s", weightName); } else { Toast.makeText(this, "Does not compute", Toast.LENGTH_LONG).show(); mTts.speak("Does not compute", TextToSpeech.QUEUE_FLUSH, null); } Editor settingsEditor = mSettings.edit(); mUnitsView.setText(mUnitsText); settingsEditor.putString("unitsText", mUnitsText); settingsEditor.putFloat("unitsRatio", (float) mUnitsRatio); settingsEditor.commit(); } super.onActivityResult(requestCode, resultCode, data); // startActivity(new Intent(Intent.ACTION_VIEW, // Uri.parse("http://www.youtube.com/watch?v=2qBgMmRMpOo"))); }
From source file:es.uma.lcc.lockpic.MainActivity.java
private void encryptImage(Intent data) { String src = data.getStringExtra("path"); int width = data.getIntExtra("width", 0); int height = data.getIntExtra("height", 0); (new EncryptionUploaderTask(src, width, height, data.getStringArrayListExtra("rectangles"), MainActivity.this)).execute(); }
From source file:com.example.casthelloworld.MainActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == REQUEST_CODE && resultCode == RESULT_OK) { ArrayList<String> matches = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS); if (matches.size() > 0) { Log.d(TAG, matches.get(0));/*from w w w.j av a 2 s.c o m*/ sendMessage(matches.get(0)); } } super.onActivityResult(requestCode, resultCode, data); }
From source file:com.ola.insta.BookingAcivity.java
/** * Receiving speech input/*from ww w.j a v a 2s .c o m*/ * */ @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == RESULT_OK && null != data) { switch (requestCode) { case REQ_CODE_SPEECH_INPUT: ArrayList<String> result = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS); boolean isMatched = false; for (String string : result) { if (string.contains(Constants.VOICE_MESSAGE)) { /* * Toast.makeText( getApplicationContext(), * getApplicationContext().getString( * R.string.cab_booked), Toast.LENGTH_SHORT).show(); */ // Call REST API if (Utilities.isNetworkAvailable(this)) { new GetCabBookingRequestTask().execute(); } else { Utilities mUltilities = new Utilities(); mUltilities.showDialogConfirm(BookingAcivity.this, "Message", "Please check network connection", true).show(); } isMatched = true; break; } } if (!isMatched) { speakOut("Please try again!"); Toast.makeText(getApplicationContext(), getApplicationContext().getString(R.string.speech_try_again), Toast.LENGTH_SHORT) .show(); } break; case REQ_CODE_SELECT_CONTACT: Uri uri = data.getData(); String id = uri.getLastPathSegment(); Cursor contact = getContentResolver().query(Phone.CONTENT_URI, null, Phone.CONTACT_ID + "=?", new String[] { id }, null); if (contact.moveToFirst()) { if (contact.getString(contact.getColumnIndex(Phone.HAS_PHONE_NUMBER)) != null) { final String contactName = contact.getString(contact.getColumnIndex(Phone.DISPLAY_NAME)); final String phoneNum = contact.getString(contact.getColumnIndex(Phone.NUMBER)); MaterialDialog dialog = new MaterialDialog(context, context.getString(R.string.emergency_contact), "Name : " + contactName + "\nNumber : " + phoneNum, context.getString(R.string.add), context.getString(R.string.cancel)); dialog.setOnAcceptButtonClickListener(new OnClickListener() { @Override public void onClick(View v) { saveToShrPref(contactName, phoneNum); Toast.makeText(context, "Emergency contact saved successfully!", Toast.LENGTH_LONG) .show(); } }); dialog.setOnCancelButtonClickListener(new OnClickListener() { @Override public void onClick(View v) { } }); dialog.show(); } else Toast.makeText(context, context.getString(R.string.contact_dont_have_number), Toast.LENGTH_LONG).show(); } break; default: break; } } }
From source file:com.zhangyp.higo.drawingboard.fragment.SketchFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == ImageSelector.IMAGE_REQUEST_CODE && resultCode == Activity.RESULT_OK && data != null) { // Get Image Path List List<String> pathList = data.getStringArrayListExtra(ImageSelectorActivity.EXTRA_RESULT); for (String path : pathList) { Log.i("ImagePathList", path); Glide.with(this).load(path).asBitmap().centerCrop().into(new SimpleTarget<Bitmap>() { @Override//from w w w. j ava 2 s . c om public void onResourceReady(Bitmap resource, GlideAnimation glideAnimation) { // Do something with bitmap here. init(resource); } }); } } }