Example usage for android.content Intent getStringArrayListExtra

List of usage examples for android.content Intent getStringArrayListExtra

Introduction

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

Prototype

public ArrayList<String> getStringArrayListExtra(String name) 

Source Link

Document

Retrieve extended data from the intent.

Usage

From source file:org.awesomeapp.messenger.ui.AddContactActivity.java

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

    if (resultCode == RESULT_OK) {
        if (requestCode == OnboardingManager.REQUEST_SCAN) {

            ArrayList<String> resultScans = resultIntent.getStringArrayListExtra("result");
            for (String resultScan : resultScans) {

                try {
                    if (resultScan.startsWith("xmpp:")) {
                        String address = XmppUriHelper.parse(Uri.parse(resultScan))
                                .get(XmppUriHelper.KEY_ADDRESS);
                        String fingerprint = XmppUriHelper.getOtrFingerprint(resultScan);

                        new AddContactAsyncTask(mApp.getDefaultProviderId(), mApp.getDefaultAccountId(), mApp)
                                .execute(address, fingerprint);

                        Intent intent = new Intent();
                        intent.putExtra(ContactsPickerActivity.EXTRA_RESULT_USERNAME, address);
                        intent.putExtra(ContactsPickerActivity.EXTRA_RESULT_PROVIDER,
                                mApp.getDefaultProviderId());
                        setResult(RESULT_OK, intent);

                    } else {
                        //parse each string and if they are for a new user then add the user
                        String[] parts = OnboardingManager.decodeInviteLink(resultScan);
                        String address = parts[0];
                        String fingerprint = null, nickname = null;
                        if (parts.length > 1)
                            fingerprint = parts[1];
                        if (parts.length > 2)
                            nickname = parts[2];

                        new AddContactAsyncTask(mApp.getDefaultProviderId(), mApp.getDefaultAccountId(), mApp)
                                .execute(address, fingerprint, nickname);

                        Intent intent = new Intent();
                        intent.putExtra(ContactsPickerActivity.EXTRA_RESULT_USERNAME, address);
                        intent.putExtra(ContactsPickerActivity.EXTRA_RESULT_PROVIDER,
                                mApp.getDefaultProviderId());
                        setResult(RESULT_OK, intent);
                    }/*from  ww  w  .  jav  a 2 s  .  com*/

                    //if they are for a group chat, then add the group
                } catch (Exception e) {
                    Log.w(ImApp.LOG_TAG, "error parsing QR invite link", e);
                }
            }
        }

        finish();

    }

}

From source file:android.support.v17.leanback.app.SearchSupportFragment.java

/**
 * Sets the text of the search query based on the {@link RecognizerIntent#EXTRA_RESULTS} in
 * the given intent, and optionally submit the query.  If more than one result is present
 * in the results list, the first will be used.
 *
 * @param intent Intent received from a speech recognition service.
 * @param submit Whether to submit the query.
 *//* w w w . j a v  a  2 s. c  o  m*/
public void setSearchQuery(Intent intent, boolean submit) {
    ArrayList<String> matches = intent.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
    if (matches != null && matches.size() > 0) {
        setSearchQuery(matches.get(0), submit);
    }
}

From source file:com.qiusheng.cast.CastActivity.java

/**
 * Initializes MediaRouter information and prepares for Cast device
 * detection upon creating this activity.
 *//* w w w  .  ja v  a  2s . c o m*/
@Override
protected void onCreate(Bundle savedInstanceState) {
    logVIfEnabled(TAG, "onCreate called");
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_cast);

    mCastContext = new CastContext(getApplicationContext());
    mMedia = new CastMedia(null, null);
    mMetaData = new ContentMetadata();

    mDialogFactory = new SampleMediaRouteDialogFactory();

    MediaRouteHelper.registerMinimalMediaRouteProvider(mCastContext, this);
    mMediaRouter = MediaRouter.getInstance(getApplicationContext());
    mMediaRouteSelector = MediaRouteHelper.buildMediaRouteSelector(MediaRouteHelper.CATEGORY_CAST);

    mMediaRouteButton = (MediaRouteButton) findViewById(R.id.media_route_button);
    mMediaRouteButton.setRouteSelector(mMediaRouteSelector);
    mMediaRouteButton.setDialogFactory(mDialogFactory);
    mMediaRouterCallback = new MyMediaRouterCallback();

    mStatusText = (TextView) findViewById(R.id.play_status_text);
    mCurrentlyPlaying = (TextView) findViewById(R.id.currently_playing);
    mCurrentlyPlaying.setText(getString(R.string.tap_to_select));

    mPlayPauseButton = (ImageButton) findViewById(R.id.play_pause_button);
    mStopButton = (ImageButton) findViewById(R.id.stop_button);
    initButtons();

    myThread = null;
    Runnable runnable = new StatusRunner();
    myThread = new Thread(runnable);
    logVIfEnabled(TAG, "Starting statusRunner thread");
    myThread.start();

    Intent intent = getIntent();
    String url = intent.getStringExtra("MEDIA_URL");
    urls = intent.getStringArrayListExtra("MEDIA_URL_LIST");
    if (urls == null || urls.size() == 0) {
        urls = new ArrayList<String>();
        urls.add(url);
    }
    title = intent.getStringExtra("MEDIA_TITLE");

    if (title == null || title.isEmpty())
        title = urls.get(0);

    this.mediaSelected(new CastMedia(title, urls.get(0)));
    nextUrl++;
}

From source file:de.janniskilian.xkcdreader.presentation.components.showcomics.ShowComicsActivity.java

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

    if (resultCode == Activity.RESULT_OK) {
        if (requestCode == REQ_VOICE_INPUT) {
            final String text = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS).get(0);
            presenter.onVoiceInputResult(text);
        }/*from w  ww  .  j  av  a 2 s  .c  o  m*/
    }
}

From source file:com.meetingninja.csse.MainActivity.java

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

    if (requestCode == 3)
        frag_notes.populateList();//w  ww  . j a v  a  2s.  c  om

    if (requestCode == VOICE_RECOGNITION_REQUEST_CODE && resultCode == RESULT_OK) {
        ArrayList<String> thingsYouSaid = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
        if (thingsYouSaid.contains("meetings")) {
            selectItem(DrawerLabel.MEETINGS.getPosition());
        } else if (thingsYouSaid.contains("groups")) {
            selectItem(DrawerLabel.GROUPS.getPosition());
        } else if (thingsYouSaid.contains("notes")) {
            selectItem(DrawerLabel.NOTES.getPosition());
        } else if (thingsYouSaid.contains("profile")) {
            selectItem(DrawerLabel.PROFILE.getPosition());
        } else if (thingsYouSaid.contains("tasks")) {
            selectItem(DrawerLabel.TASKS.getPosition());
        } else if (thingsYouSaid.contains("projects")) {
            selectItem(DrawerLabel.PROJECTS.getPosition());
        } else if (thingsYouSaid.contains("contacts")) {
            selectItem(DrawerLabel.CONTACTS.getPosition());
        }
    }
}

From source file:com.gigathinking.simpleapplock.AppListFragment.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
    case 22:/*from   w  w  w.ja v  a 2s .c  o m*/
        if (data == null) {
            return;
        }
        ArrayList<String> packageNames = data.getStringArrayListExtra(Intent.EXTRA_TEXT);
        if (packageNames != null) {
            try {
                for (String packageName : packageNames) {
                    String label = getActivity().getPackageManager()
                            .getApplicationLabel(
                                    getActivity().getPackageManager().getApplicationInfo(packageName, 0))
                            .toString();
                    mList.add(packageName);
                    mAppMap.put(packageName, true);
                    mAdapter.notifyDataSetChanged();
                    MainActivity.getAppListData().insertApp(label, packageName, true, 0);
                }
            } catch (PackageManager.NameNotFoundException e) {
                e.printStackTrace();
            }
            LocalBroadcastManager.getInstance(getActivity())
                    .sendBroadcast(new Intent(AppLockApplication.UPDATE_LIST));
            String message = getActivity().getString(R.string.lock_message_selected_apps);
            Toast.makeText(getActivity(), message, Toast.LENGTH_SHORT).show();
        }
        if (mList.size() != 0) {
            showInitialStart(false);
        }
        if (mPrefs.getInt("ad_count", 0) < 5) {
            new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                    if (interstitial.isLoaded()) {
                        interstitial.show();
                    }
                }
            }, 700);
        }
        break;
    case 24: {
        if (resultCode == LockPatternActivity.RESULT_OK) {
            mPrefs.edit().putBoolean(AppLockApplication.LOCKSET, true).commit();
            LocalBroadcastManager.getInstance(getActivity())
                    .sendBroadcast(new Intent(AppLockApplication.LAUNCH_PICKER));
        }
        break;
    }
    default:
        break;
    }
}

From source file:agricultural.nxt.agriculturalsupervision.Activity.company.CompanyAddActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    List<String> photos = null;
    switch (requestCode) {
    case 1:/*from   w ww .j  a  va  2s  .com*/
        if (data != null) {
            photos = data.getStringArrayListExtra(PhotoPicker.KEY_SELECTED_PHOTOS);
        }
        selectedPhotos1.clear();
        if (photos != null) {
            selectedPhotos1.addAll(photos);
        }
        photoAdapter1.notifyDataSetChanged();
        break;
    case 2:
        if (data != null) {
            photos = data.getStringArrayListExtra(PhotoPicker.KEY_SELECTED_PHOTOS);
        }
        selectedPhotos2.clear();
        if (photos != null) {
            selectedPhotos2.addAll(photos);
        }
        photoAdapter2.notifyDataSetChanged();
        break;
    }
}

From source file:com.locosoft.imageselector.MultiImageSelectorActivity.java

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

    mFakeR = new FakeR(this);
    setContentView(mFakeR.getId("layout", "activity_image_selector"));

    Intent intent = getIntent();
    mDefaultCount = intent.getIntExtra(EXTRA_SELECT_COUNT, 9);
    int mode = intent.getIntExtra(EXTRA_SELECT_MODE, MODE_MULTI);
    boolean isShow = intent.getBooleanExtra(EXTRA_SHOW_CAMERA, true);
    if (mode == MODE_MULTI && intent.hasExtra(EXTRA_DEFAULT_SELECTED_LIST)) {
        resultList = intent.getStringArrayListExtra(EXTRA_DEFAULT_SELECTED_LIST);
    }/* w  ww. j av  a2  s . c om*/

    desiredWidth = intent.getIntExtra(EXTRA_WIDTH, 0);
    desiredHeight = intent.getIntExtra(EXTRA_HEIGHT, 0);
    quality = intent.getIntExtra(EXTRA_QUALITY, 0);
    fixRotation = intent.getBooleanExtra(EXTRA_FIXROTATION, false);

    Bundle bundle = new Bundle();
    bundle.putInt(MultiImageSelectorFragment.EXTRA_SELECT_COUNT, mDefaultCount);
    bundle.putInt(MultiImageSelectorFragment.EXTRA_SELECT_MODE, mode);
    bundle.putBoolean(MultiImageSelectorFragment.EXTRA_SHOW_CAMERA, isShow);
    bundle.putStringArrayList(MultiImageSelectorFragment.EXTRA_DEFAULT_SELECTED_LIST, resultList);

    getSupportFragmentManager().beginTransaction().add(mFakeR.getId("id", "imageselector_image_grid"),
            Fragment.instantiate(this, MultiImageSelectorFragment.class.getName(), bundle)).commit();

    // back button
    findViewById(mFakeR.getId("id", "imageselector_btn_back")).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            setResult(RESULT_CANCELED);
            finish();
        }
    });

    // done button
    mSubmitButton = (Button) findViewById(mFakeR.getId("id", "imageselector_commit"));
    if (resultList == null || resultList.size() <= 0) {
        mSubmitButton.setText(mFakeR.getId("string", "imageselector_done"));
        mSubmitButton.setEnabled(false);
    } else {
        mSubmitButton.setText(getResources().getString(mFakeR.getId("string", "imageselector_done")) + "("
                + resultList.size() + "/" + mDefaultCount + ")");

        mSubmitButton.setEnabled(true);
    }
    mSubmitButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (resultList != null && resultList.size() > 0) {
                // return the selection array list
                if (desiredHeight == 0 && desiredWidth == 0 && quality == 100 && !fixRotation) {
                    Intent data = new Intent();
                    data.putStringArrayListExtra(EXTRA_RESULT, resultList);
                    setResult(RESULT_OK, data);
                    finish();
                } else {
                    postProcessImages();
                }
            }
        }
    });

    progress = new ProgressDialog(this);
    progress.setTitle(getResources().getString(mFakeR.getId("string", "imageselector_progress_title")));
    progress.setMessage(getResources().getString(mFakeR.getId("string", "imageselector_progress_content")));
}

From source file:com.kyleszombathy.sms_scheduler.MessageAlarmReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    this.context = context;
    boolean sendSuccessFlag = true;

    // Get wakelock
    Intent service = new Intent(context, MessageAlarmReceiver.class);

    // Start the service, keeping the device awake while it is launching.
    Log.i("SimpleWakefulReceiver", "Starting service @ " + SystemClock.elapsedRealtime());
    startWakefulService(context, service);

    // Get data from intent
    ArrayList<String> phoneList = intent.getStringArrayListExtra("pNum");
    String messageContent = intent.getStringExtra("message");
    int alarmNumber = intent.getIntExtra("alarmNumber", -1);
    ArrayList<String> nameList = intent.getStringArrayListExtra("nameList");

    // Split message, regardless if needed - just in case I have the message length number wrong
    final ArrayList<String> messageArrayList = smsManager.divideMessage(messageContent);

    // Sends to multiple recipients
    for (int i = 0; i < phoneList.size(); i++) {
        // Send message and retrieve
        boolean result = sendSMSMessage(phoneList.get(i), messageArrayList);
        if (!result) {
            sendSuccessFlag = false;//ww w  .  j a v a 2  s  . co  m
        }
    }

    /* Register for SMS send action */
    context.getApplicationContext().registerReceiver(new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            String result = "";
            final String[] TRANSMISSION_TYPE = { "Transmission successful", "Transmission failed", "Radio off",
                    "No PDU defined", "No service" };

            switch (getResultCode()) {
            case Activity.RESULT_OK:
                result = TRANSMISSION_TYPE[0];
                break;
            case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
                result = TRANSMISSION_TYPE[1];
                break;
            case SmsManager.RESULT_ERROR_RADIO_OFF:
                result = TRANSMISSION_TYPE[2];
                break;
            case SmsManager.RESULT_ERROR_NULL_PDU:
                result = TRANSMISSION_TYPE[3];
                break;
            case SmsManager.RESULT_ERROR_NO_SERVICE:
                result = TRANSMISSION_TYPE[4];
                break;
            }
            Log.i(TAG, result + " for message " + messageArrayList.toString());
            // Handle error
            if (!Objects.equals(result, TRANSMISSION_TYPE[0])) {
                //messageSendSuccess[0] = false;
            }
        }
    }, new IntentFilter(SENT));

    // Create notification message
    String notificationMessage = Tools.createSentString(context, nameList, 1, sendSuccessFlag);

    // Send notification if message send successfull
    if (sendSuccessFlag) {
        sendNotification(context, notificationMessage, messageContent, true, nameList);
    } else {
        sendNotification(context, notificationMessage, messageContent, false, nameList);
    }
    // Archive, regardless of send success or not
    markAsSent(context, notificationMessage, alarmNumber);
    // Release wakelock
    completeWakefulIntent(service);
}