List of usage examples for android.content Intent getStringArrayListExtra
public ArrayList<String> getStringArrayListExtra(String name)
From source file:root.magicword.MagicWord.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == SPEECH_REQUEST_CODE) { if (resultCode == RESULT_OK) { ArrayList<String> matches = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS); if (matches.size() == 0) { tts.speak("Heard nothing", TextToSpeech.QUEUE_FLUSH, null); } else { mostLikelyThingHeard = matches.get(0); String magicWord = this.getResources().getString(R.string.magicword); if (mostLikelyThingHeard.equals(magicWord)) { tts.speak("You said the magic word!", TextToSpeech.QUEUE_FLUSH, null); } else { tts.speak("The magic word is " + mostLikelyThingHeard + " try again", TextToSpeech.QUEUE_FLUSH, null); }/*from w ww . j a v a 2s . c o m*/ } // result.setText("heard: " + matches); result.setText("heard: " + mostLikelyThingHeard); } else { Log.d(TAG, "result NOT ok"); } } super.onActivityResult(requestCode, resultCode, data); }
From source file:org.musicbrainz.mobile.activity.DashboardActivity.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent intent) { if (requestCode == IntentIntegrator.BARCODE_REQUEST) { IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent); if (scanResult.getContents() != null) { Intent barcodeResult = new Intent(this, ReleaseActivity.class); barcodeResult.putExtra(Extra.BARCODE, scanResult.getContents()); startActivity(barcodeResult); }/*from w w w. ja v a2 s . co m*/ } else if (requestCode == COLLECTION_LOGIN_REQUEST && isUserLoggedIn()) { startActivity(IntentFactory.getCollectionList(getApplicationContext())); } else if (intent != null) { if (resultCode == Activity.RESULT_OK) { ArrayList<String> matches = intent.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Did you say?"); final ListView modeList = new ListView(this); String[] arrayMatches = matches.toArray(new String[matches.size()]); ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.activity_voicetotexts, R.id.voicetotexts_item, arrayMatches); modeList.setAdapter(adapter); builder.setView(modeList); final Dialog dialog = builder.create(); modeList.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { String selectedFromList = (String) (modeList.getItemAtPosition(position)); dialog.dismiss(); if (selectedFromList != null) { FragmentManager fm = getSupportFragmentManager(); SearchFragment sf = (SearchFragment) fm.findFragmentById(R.id.search_fragment); sf.setSearchField(selectedFromList); } } }); dialog.show(); } } }
From source file:org.storymaker.app.PublishFragment.java
public void onChooseAccountDialogResult(int resultCode, Intent intent) { if (resultCode == Activity.RESULT_OK) { Timber.d("Choose Accounts dialog return ok"); if (intent.hasExtra(ChooseAccountFragment.EXTRAS_ACCOUNT_KEYS)) { ArrayList<String> siteKeys = intent .getStringArrayListExtra(ChooseAccountFragment.EXTRAS_ACCOUNT_KEYS); if (!siteKeys.isEmpty()) { Timber.d("selected sites: " + siteKeys); mSiteKeys = siteKeys.toArray(new String[siteKeys.size()]); useTor = intent.getBooleanExtra(SiteController.VALUE_KEY_USE_TOR, false); publishToStoryMaker = intent.getBooleanExtra(SiteController.VALUE_KEY_PUBLISH_TO_STORYMAKER, false);//ww w.ja v a 2s .c om shareAuthor = intent.getBooleanExtra(ArchiveMetadataActivity.INTENT_EXTRA_SHARE_AUTHOR, false); shareTitle = intent.getBooleanExtra(ArchiveMetadataActivity.INTENT_EXTRA_SHARE_TITLE, false); shareTags = intent.getBooleanExtra(ArchiveMetadataActivity.INTENT_EXTRA_SHARE_TAGS, false); shareDescription = intent .getBooleanExtra(ArchiveMetadataActivity.INTENT_EXTRA_SHARE_DESCRIPTION, false); shareLocation = intent.getBooleanExtra(ArchiveMetadataActivity.INTENT_EXTRA_SHARE_LOCATION, false); licenseUrl = intent.getStringExtra(ArchiveMetadataActivity.INTENT_EXTRA_LICENSE_URL); startPublish(); } else { Utils.toastOnUiThread(mActivity, mActivity.getString(R.string.no_site_selected)); } } else { Utils.toastOnUiThread(mActivity, mActivity.getString(R.string.no_site_selected)); } } else { Timber.d("Choose Accounts dialog canceled"); showPlayAndUpload(true); } }
From source file:com.neighbor.ex.tong.ui.activity.MainActivity2Activity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); switch (requestCode) { case REQ_CODE_SPEECH_INPUT: if (resultCode == RESULT_OK && null != data) { ArrayList<String> result = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS); String regex = "[0-9]{4}"; String resultData = result.get(0); if (resultData.matches(regex)) { inputCarNo.postDelayed(new Runnable() { @Override//from ww w . j a v a 2s. c om public void run() { inputCarNo.showDropDown(); } }, 500); inputCarNo.setText(resultData); inputCarNo.setSelection(inputCarNo.getText().length()); } } break; case PICK_CAMERA_REQUEST: if (resultCode == RESULT_OK && null != data) { String carNum = data.getStringExtra("carNum"); if (carNum.equalsIgnoreCase("??")) { Toast.makeText(MainActivity2Activity.this, "?? . ? .", Toast.LENGTH_SHORT).show(); inputCarNo.setText(""); } else { String resultCarNo = data.getStringExtra("resultCarNo"); Log.d("hts", "resultCarNo : " + resultCarNo); resultCarNo = resultCarNo.substring(resultCarNo.length() - 4, resultCarNo.length()); inputCarNo.postDelayed(new Runnable() { @Override public void run() { inputCarNo.showDropDown(); } }, 500); inputCarNo.setText(resultCarNo); inputCarNo.setSelection(inputCarNo.getText().length()); } } break; } }
From source file:com.grarak.kerneladiutor.fragments.tools.ProfileFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (data == null) return;//from w w w . j ava 2 s.co m if (requestCode == 0 || requestCode == 2) { LinkedHashMap<String, String> commandsList = new LinkedHashMap<>(); ArrayList<String> ids = data.getStringArrayListExtra(ProfileActivity.RESULT_ID_INTENT); ArrayList<String> commands = data.getStringArrayListExtra(ProfileActivity.RESULT_COMMAND_INTENT); for (int i = 0; i < ids.size(); i++) { commandsList.put(ids.get(i), commands.get(i)); } if (requestCode == 0) { create(commandsList); } else { Profiles.ProfileItem profileItem = mProfiles.getAllProfiles() .get(data.getIntExtra(ProfileActivity.POSITION_INTENT, 0)); for (Profiles.ProfileItem.CommandItem commandItem : profileItem.getCommands()) { if (ids.contains(commandItem.getPath())) { profileItem.delete(commandItem); } } for (String path : commandsList.keySet()) { profileItem.putCommand(new Profiles.ProfileItem.CommandItem(path, commandsList.get(path))); } mProfiles.commit(); } } else if (requestCode == 1) { ImportProfile importProfile = new ImportProfile(data.getStringExtra(FilePickerActivity.RESULT_INTENT)); if (!importProfile.readable()) { Utils.toast(R.string.import_malformed, getActivity()); return; } if (!importProfile.matchesVersion()) { Utils.toast(R.string.import_wrong_version, getActivity()); return; } showImportDialog(importProfile); } else if (requestCode == 3) { reload(); } }
From source file:br.liveo.searchliveo.SearchLiveo.java
public void resultVoice(int requestCode, int resultCode, Intent data) { if (requestCode == SearchLiveo.REQUEST_CODE_SPEECH_INPUT) { if (resultCode == Activity.RESULT_OK && null != data) { ArrayList<String> result = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS); mEdtSearch.setText(result.get(0)); }/*from w w w . j a va 2s.com*/ } }
From source file:br.liveo.searchliveo.SearchCardLiveo.java
public void resultVoice(int requestCode, int resultCode, Intent data) { if (requestCode == SearchCardLiveo.REQUEST_CODE_SPEECH_INPUT) { if (resultCode == Activity.RESULT_OK && null != data) { ArrayList<String> result = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS); mEdtSearch.setText(result.get(0)); }/* ww w . j a v a 2 s. co m*/ } }
From source file:com.amaze.filemanager.services.ExtractService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { Bundle b = new Bundle(); b.putInt("id", startId); epath = PreferenceManager.getDefaultSharedPreferences(this).getString("extractpath", ""); mNotifyManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); String file = intent.getStringExtra("zip"); eentries = intent.getBooleanExtra("entries1", false); if (eentries) { entries = intent.getStringArrayListExtra("entries"); }/* w ww . j av a 2s . c o m*/ b.putString("file", file); DataPackage intent1 = new DataPackage(); intent1.setName(file); intent1.setTotal(0); intent1.setDone(0); intent1.setId(startId); intent1.setP1(0); intent1.setCompleted(false); hash1.put(startId, intent1); Intent notificationIntent = new Intent(this, MainActivity.class); notificationIntent.setAction(Intent.ACTION_MAIN); notificationIntent.putExtra("openprocesses", true); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); mBuilder = new NotificationCompat.Builder(cd); mBuilder.setContentIntent(pendingIntent); mBuilder.setContentTitle(getResources().getString(R.string.extracting)) .setContentText(new File(file).getName()).setSmallIcon(R.drawable.ic_doc_compressed); hash.put(startId, true); new Doback().execute(b); return START_STICKY; }
From source file:org.thoughtcrime.securesms.GroupCreateActivity.java
@Override public void onActivityResult(int reqCode, int resultCode, Intent data) { super.onActivityResult(reqCode, resultCode, data); Uri outputFile = Uri.fromFile(new File(getCacheDir(), "cropped")); if (data == null || resultCode != Activity.RESULT_OK) return;/*from www. j a v a2 s .c om*/ switch (reqCode) { case PICK_CONTACT: List<String> selected = data.getStringArrayListExtra("contacts"); for (String contact : selected) { Recipient recipient = RecipientFactory.getRecipientsFromString(this, contact, false) .getPrimaryRecipient(); if (!selectedContacts.contains(recipient) && (existingContacts == null || !existingContacts.contains(recipient)) && recipient != null) { addSelectedContact(recipient); } } syncAdapterWithSelectedContacts(); break; case Crop.REQUEST_PICK: new Crop(data.getData()).output(outputFile).asSquare().start(this); break; case Crop.REQUEST_CROP: Intent decodeCropAndSet = new Intent(this, DecodeCropAndSetService.class); decodeCropAndSet.putExtra("masterSecret", masterSecret); decodeCropAndSet.putExtra("avatarUri", Crop.getOutput(data)); this.startService(decodeCropAndSet); } }
From source file:dk.ciid.android.infobooth.activities.SubscriptionFinalActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { /* Variables received through Intent */ Intent openActivity = getIntent(); // this is just for example purpose isInDebugMode = openActivity.getBooleanExtra("isInDebugMode", true); // should the app send a welcome sms after subscribing? phoneNum = openActivity.getStringExtra("phoneNum"); // get the phonenumber submitted in the last activity selectedService = openActivity.getIntExtra("selectedService", 1); // array position of selected service in last activity serviceIdItems = openActivity.getStringArrayListExtra("serviceIdItems"); // arraylist of service id's (in database) serviceNameItems = openActivity.getStringArrayListExtra("serviceNameItems"); // arraylist of service names serviceDescItems = openActivity.getStringArrayListExtra("serviceDescItems"); // arraylist of service descriptions voice1 = openActivity.getStringExtra("voice1"); // path to voice file 1 voice2 = openActivity.getStringExtra("voice2"); // path to voice file 2 voice3 = openActivity.getStringExtra("voice3"); // path to voice file 3 voice4 = openActivity.getStringExtra("voice4"); // path to voice file 4 voice5 = openActivity.getStringExtra("voice5"); // path to voice file 5 voice6 = openActivity.getStringExtra("voice6"); // path to voice file 6 /* Variables received through Intent */ // TODO Auto-generated method stub super.onCreate(savedInstanceState); /* ARDUINO COMMUNICATION STUFF ********************************************/ // a reference to the USB system service is obtained so that you can call its methods later on mUsbManager = UsbManager.getInstance(this); mPermissionIntent = PendingIntent.getBroadcast(this, 0, new Intent(ACTION_USB_PERMISSION), 0); IntentFilter filter = new IntentFilter(ACTION_USB_PERMISSION); filter.addAction(UsbManager.ACTION_USB_ACCESSORY_DETACHED); registerReceiver(mUsbReceiver, filter); if (getLastNonConfigurationInstance() != null) { mAccessory = (UsbAccessory) getLastNonConfigurationInstance(); openAccessory(mAccessory);//from w w w. j a va 2 s. com } /* ARDUINO COMMUNICATION STUFF ********************************************/ gestureScanner = new GestureDetector(this); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.activity_subscription_final); if (!isInDebugMode) { try { //SmsManager smsManager = SmsManager.getDefault(); //smsManager.sendTextMessage(phoneNumber, null, SMSMessage, null, null); Toast.makeText(getApplicationContext(), "Thanks for subscribing!", Toast.LENGTH_SHORT).show(); } catch (Exception e) { Toast.makeText(getApplicationContext(), "SMS failed, please try again later!", Toast.LENGTH_SHORT) .show(); e.printStackTrace(); } } else { Toast.makeText(getApplicationContext(), "Debug mode - no SMS sent to save money :)", Toast.LENGTH_SHORT) .show(); } // Set up sound playback initMediaPlayer(); }