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:ua.naiksoftware.rxgoogle.ResolutionActivity.java

private void handleIntent(Intent intent) {
    if (intent.hasExtra(ARG_PERMISSIONS_LIST)) { // Resolve some permissions
        permissionsRequestCode = intent.getIntExtra(ARG_PERMISSIONS_REQUEST_CODE, -1);
        List<String> permissions = intent.getStringArrayListExtra(ARG_PERMISSIONS_LIST);
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
            setPermissionsResultAndFinish(permissions, permissions);
            return;
        }/*w w  w.  j a  v  a2 s .  c  o m*/

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            requestPermissions(permissions.toArray(new String[permissions.size()]), REQUEST_CODE_PERMISSIONS);
        }
    } else if (intent.hasExtra(ARG_RESOLVE_STATUS)) { // Resolve Status object
        status = intent.getParcelableExtra(ARG_RESOLVE_STATUS);
        try {
            status.startResolutionForResult(this, REQUEST_CODE_STATUS);
        } catch (IntentSender.SendIntentException e) {
            e.printStackTrace();
        }
    } else { // Resolve resolution for google api client
        try {
            ConnectionResult connectionResult = intent.getParcelableExtra(ARG_CONNECTION_RESULT);
            connectionResult.startResolutionForResult(this, REQUEST_CODE_RESOLUTION);
            resolutionShown = true;
        } catch (IntentSender.SendIntentException | NullPointerException e) {
            setResolutionResultAndFinish(Activity.RESULT_CANCELED);
        }
    }
}

From source file:com.example.SpeechRecognizer.java

/**
 * Handle the results from the recognition activity.
 *//*from w  ww.ja  va2s . c o m*/
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == Activity.RESULT_OK) {
        // Fill the list view with the strings the recognizer thought it could have heard
        ArrayList<String> matches = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
        ReturnSpeechResults(requestCode, matches);
    } else {
        // Failure - Let the caller know
        ReturnSpeechFailure(resultCode);
    }

    super.onActivityResult(requestCode, resultCode, data);
}

From source file:io.imoji.sdk.editor.ImojiCreateService.java

@Override
protected void onHandleIntent(Intent intent) {
    final String token = intent.getStringExtra(CREATE_TOKEN_BUNDLE_ARG_KEY); //the token that will contain the bitmap in memory and also used to bind to the newly created imoji
    List<String> tags = intent.getStringArrayListExtra(TAGS_BUNDLE_ARG_KEY);

    Bitmap b = EditorBitmapCache.getInstance().remove(token);
    if (b == null) {
        //notify failure
        notifyFailure(token);/*  w  w  w  . j  a  va  2s .c  o  m*/
        return;
    }

    final CountDownLatch latch = new CountDownLatch(1);
    this.imojiSession.createImojiWithRawImage(b, b, tags)
            .executeAsyncTask(new ApiTask.WrappedAsyncTask<CreateImojiResponse>() {
                @Override
                protected void onPostExecute(CreateImojiResponse createImojiResponse) {
                    notifySuccess(createImojiResponse.getImoji(), token);
                    latch.countDown();
                }

                @Override
                protected void onError(@NonNull Throwable error) {
                    notifyFailure(token);
                    latch.countDown();
                }
            });

    waitForCreateToFinish(latch, token);

    //clear editor bitmaps excpet for the outlined one
    EditorBitmapCache.getInstance().clearNonOutlinedBitmaps();

}

From source file:com.google.developers.actions.debugger.MainActivity.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == RECOGNIZER_REQ_CODE && resultCode == RESULT_OK) {
        ArrayList<String> matches = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
        if (!matches.isEmpty()) {
            for (String match : matches) {
                if (match.startsWith(PLAY_PREFIX)) {
                    askCayley(match.substring(PLAY_PREFIX.length()));
                    Toast.makeText(this, match, Toast.LENGTH_LONG).show();
                    break;
                }//from  www . j av a 2 s . c  o  m
            }
            //Result code for various error.
        } else if (resultCode == RecognizerIntent.RESULT_AUDIO_ERROR) {
            Utils.showError(MainActivity.this, "Audio Error");
        } else if (resultCode == RecognizerIntent.RESULT_CLIENT_ERROR) {
            Utils.showError(MainActivity.this, "Client Error");
        } else if (resultCode == RecognizerIntent.RESULT_NETWORK_ERROR) {
            Utils.showError(MainActivity.this, "Network Error");
        } else if (resultCode == RecognizerIntent.RESULT_NO_MATCH) {
            Utils.showError(MainActivity.this, "No Match");
        } else if (resultCode == RecognizerIntent.RESULT_SERVER_ERROR) {
            Utils.showError(MainActivity.this, "Server Error");
        }
    }
}

From source file:org.sufficientlysecure.keychain.remote.ui.dialog.RemoteDeduplicateActivity.java

@Override
protected void onStart() {
    super.onStart();

    Intent intent = getIntent();
    List<String> dupAddresses = intent.getStringArrayListExtra(EXTRA_DUPLICATE_EMAILS);
    String duplicateAddress = dupAddresses.get(0);
    String packageName = intent.getStringExtra(EXTRA_PACKAGE_NAME);

    presenter.setupFromIntentData(packageName, duplicateAddress);
    presenter.startLoaders(getSupportLoaderManager());
}

From source file:eu.power_switch.gui.fragment.configure_call.ConfigureCallDialogPage1ContactsFragment.java

@Nullable
@Override/* www .ja v a 2 s.  com*/
public View onCreateView(LayoutInflater inflater, final ViewGroup container, Bundle savedInstanceState) {
    rootView = inflater.inflate(R.layout.dialog_fragment_configure_call_page_1, container, false);

    broadcastReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            if (LocalBroadcastConstants.INTENT_CALL_PHONE_NUMBER_ADDED.equals(intent.getAction())) {
                ArrayList<String> newPhoneNumbers = intent
                        .getStringArrayListExtra(AddPhoneNumberDialog.KEY_PHONE_NUMBER);

                for (String number : newPhoneNumbers) {
                    if (!phoneNumbers.contains(number)) {
                        phoneNumbers.add(number);
                    }
                }

                phoneNumberRecyclerViewAdapter.notifyDataSetChanged();
            }
        }
    };

    recyclerViewContacts = (RecyclerView) rootView.findViewById(R.id.recyclerView_contacts);
    phoneNumberRecyclerViewAdapter = new PhoneNumberRecyclerViewAdapter(getActivity(), phoneNumbers);
    recyclerViewContacts.setAdapter(phoneNumberRecyclerViewAdapter);
    phoneNumberRecyclerViewAdapter
            .setOnDeleteClickListener(new PhoneNumberRecyclerViewAdapter.OnItemClickListener() {
                @Override
                public void onItemClick(View itemView, final int position) {
                    new AlertDialog.Builder(getContext()).setTitle(R.string.delete)
                            .setMessage(R.string.are_you_sure)
                            .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int which) {
                                    try {
                                        phoneNumbers.remove(position);
                                        phoneNumberRecyclerViewAdapter.notifyDataSetChanged();
                                        notifyConfigurationChanged();
                                    } catch (Exception e) {
                                        StatusMessageHandler.showErrorMessage(getActivity(), e);
                                    }
                                }
                            }).setNeutralButton(android.R.string.cancel, null).show();
                }
            });
    StaggeredGridLayoutManager layoutManager = new StaggeredGridLayoutManager(1,
            StaggeredGridLayoutManager.VERTICAL);
    recyclerViewContacts.setLayoutManager(layoutManager);

    final FloatingActionButton addContactFAB = (FloatingActionButton) rootView
            .findViewById(R.id.add_contact_fab);
    addContactFAB.setImageDrawable(IconicsHelper.getAddIcon(getActivity(),
            ContextCompat.getColor(getActivity(), android.R.color.white)));
    final Fragment fragment = this;
    addContactFAB.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            AddPhoneNumberDialog addPhoneNumberDialog = new AddPhoneNumberDialog();
            addPhoneNumberDialog.setTargetFragment(fragment, 0);
            addPhoneNumberDialog.show(getFragmentManager(), null);
        }
    });

    Bundle args = getArguments();
    if (args != null && args.containsKey(ConfigureCallEventDialog.CALL_EVENT_ID_KEY)) {
        callEventId = args.getLong(ConfigureCallEventDialog.CALL_EVENT_ID_KEY);
        initializeCallData(callEventId);
    }

    return rootView;
}

From source file:com.ipo.wiimote.SpeechRecognizer.java

/**
 * Handle the results from the recognition activity.
 *///from  w  w w .  j a  va2 s . com
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == Activity.RESULT_OK) {
        // Fill the list view with the strings the recognizer thought it could have heard
        ArrayList<String> matches = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
        float[] confidence = data.getFloatArrayExtra(RecognizerIntent.EXTRA_CONFIDENCE_SCORES);

        if (confidence != null) {
            Log.d(LOG_TAG, "confidence length " + confidence.length);
            Iterator<String> iterator = matches.iterator();
            int i = 0;
            while (iterator.hasNext()) {
                Log.d(LOG_TAG, "Match = " + iterator.next() + " confidence = " + confidence[i]);
                i++;
            }
        } else {
            Log.d(LOG_TAG, "No confidence" + "");
        }

        ReturnSpeechResults(requestCode, matches);
    } else {
        // Failure - Let the caller know
        ReturnSpeechFailure(resultCode);
    }

    super.onActivityResult(requestCode, resultCode, data);
}

From source file:com.andrada.sitracker.tasks.receivers.UpdateStatusNotificationReceiver.java

@Override
public void onReceive(@NotNull Context context, @NotNull Intent intent) {
    //See if there is something we can notify
    if (intent.getAction().equals(UpdateSuccessfulIntentMessage.SUCCESS_MESSAGE)) {
        int updatedAuthorsCount = intent.getIntExtra(Constants.NUMBER_OF_UPDATED_AUTHORS, 0);
        List<String> updatedAuthorNames = intent
                .getStringArrayListExtra(Constants.AUTHOR_NAMES_UPDATED_IN_SESSION);
        if (updatedAuthorsCount > 0) {
            //Notify that update successful
            sendNotification(updatedAuthorsCount, updatedAuthorNames, context);
        }//from  ww  w.java  2 s.  co m

    } else if (intent.getAction().equals(UpdateFailedIntentMessage.FAILED_MESSAGE)) {
        //Notify that update failed
        AnalyticsHelper.getInstance().sendException(UpdateFailedIntentMessage.FAILED_MESSAGE);
    }

}

From source file:com.cerema.cloud2.ui.activity.ErrorsWhileCopyingHandlerActivity.java

/**
 * {@link}/*from w  w w  .  j a va 2  s  .co m*/
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    /// read extra parameters in intent
    Intent intent = getIntent();
    mAccount = intent.getParcelableExtra(EXTRA_ACCOUNT);
    mRemotePaths = intent.getStringArrayListExtra(EXTRA_REMOTE_PATHS);
    mLocalPaths = intent.getStringArrayListExtra(EXTRA_LOCAL_PATHS);
    mStorageManager = new FileDataStorageManager(mAccount, getContentResolver());
    mHandler = new Handler();
    if (mCurrentDialog != null) {
        mCurrentDialog.dismiss();
        mCurrentDialog = null;
    }

    /// load generic layout
    setContentView(R.layout.generic_explanation);

    /// customize text message
    TextView textView = (TextView) findViewById(R.id.message);
    String appName = getString(R.string.app_name);
    String message = String.format(getString(R.string.sync_foreign_files_forgotten_explanation), appName,
            appName, appName, appName, mAccount.name);
    textView.setText(message);
    textView.setMovementMethod(new ScrollingMovementMethod());

    /// load the list of local and remote files that failed
    ListView listView = (ListView) findViewById(R.id.list);
    if (mLocalPaths != null && mLocalPaths.size() > 0) {
        mAdapter = new ErrorsWhileCopyingListAdapter();
        listView.setAdapter(mAdapter);
    } else {
        listView.setVisibility(View.GONE);
        mAdapter = null;
    }

    /// customize buttons
    Button cancelBtn = (Button) findViewById(R.id.cancel);
    Button okBtn = (Button) findViewById(R.id.ok);

    okBtn.setText(R.string.foreign_files_move);
    cancelBtn.setOnClickListener(this);
    okBtn.setOnClickListener(this);
}

From source file:com.nomprenom2.view.NameParamsFragment.java

/**
 * Receives result from select region activity, apply new regions list
 * @param requestCode//from  ww w . j  ava 2s  .  c o m
 * @param resultCode
 * @param data
 */
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == Activity.RESULT_OK && requestCode == MainActivity.GROUP_REQUEST) {
        regions.clear();
        if (data.hasExtra(MainActivity.REGIONS)) {
            regions.addAll(data.getStringArrayListExtra(MainActivity.REGIONS));
        }
        setGroupList();
    }
}