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:de.azapps.mirakel.main_activity.MainActivity.java

@Override
protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
    final boolean isOk = resultCode == Activity.RESULT_OK;
    Log.v(MainActivity.TAG, "Result:" + requestCode);
    switch (requestCode) {
    case RESULT_SPEECH_NAME:
        if (data != null) {
            final List<String> text = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
            ((EditText) findViewById(R.id.edit_name)).setText(text.get(0));
        }//from  w  w  w.  j a v a  2 s.c  o m
        break;
    case RESULT_SPEECH:
        if (data != null) {
            final List<String> text = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
            ((EditText) getTasksFragment().getFragmentView().findViewById(R.id.tasks_new)).setText(text.get(0));
        }
        break;
    case RESULT_ADD_FILE:
        if (data != null) {
            Log.d(MainActivity.TAG, "taskname " + this.currentTask.getName());
            getTaskFragment().update(this.currentTask);
        }
        break;
    case RESULT_SETTINGS:
        forceRebuildLayout();
        if (!MirakelCommonPreferences.highlightSelected()
                && ((this.oldClickedList != null) || (this.oldClickedTask == null))) {
            clearAllHighlights();
        }
        if (this.darkTheme != MirakelCommonPreferences.isDark()) {
            finish();
            if (this.startIntent == null) {
                this.startIntent = new Intent(MainActivity.this, MainActivity.class);
                this.startIntent.setAction(DefinitionsHelper.SHOW_LISTS);
                Log.wtf(MainActivity.TAG, "startIntent is null by switching theme");
            }
            startActivity(this.startIntent);
        }
        if (MirakelCommonPreferences.isTablet()) {
            forceRebuildLayout();
        } else if (this.mViewPager != null) {
            loadMenu(this.mViewPager.getCurrentItem());
        }
        if (getTasksFragment() != null) {
            getTasksFragment().updateButtons();
        }
        if (getTaskFragment() != null) {
            getTaskFragment().update(this.currentTask);
        }
        return;
    case RESULT_CAMERA:
    case RESULT_ADD_PICTURE:
        if (isOk) {
            final Task task;
            if (requestCode == MainActivity.RESULT_ADD_PICTURE) {
                task = this.currentTask;
            } else {
                task = Semantic.createTask(MirakelCommonPreferences.getPhotoDefaultTitle(),
                        Optional.fromNullable(this.currentList), false, this);
                task.save();
                if (getTasksFragment() != null) {
                    getTasksFragment().getLoaderManager().restartLoader(0, null, getTasksFragment());
                }
            }
            task.addFile(this, this.fileUri);
            getTaskFragment().update(task);
        }
        break;
    default:
        Log.w(MainActivity.TAG, "unknown activity result");
        break;
    }
}

From source file:com.androzic.vnspeech.MapFragment.java

/**
 * Receiving speech input/* ww  w .ja  va2s .c  o  m*/
 */
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    switch (requestCode) {
    case REQ_CODE_SPEECH_INPUT: {
        if (resultCode == Activity.RESULT_OK && null != data) {
            ArrayList<String> result = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
            String text = result.get(0);
            doTalkCommand(text);
            //TODO AI algorithm here
            //You can do language analyze here
        }
        break;
    }

    }
}

From source file:com.amaze.filemanager.services.ZipTask.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    Bundle b = new Bundle();
    zpath = PreferenceManager.getDefaultSharedPreferences(this).getString("zippath", "");
    mNotifyManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    String name = intent.getStringExtra("name");
    if ((zpath != null && zpath.length() != 0)) {
        if (zpath.endsWith("/"))
            name = zpath + new File(name).getName();
        else/*  w w w  . ja v  a2s . co  m*/
            name = zpath + "/" + new File(name).getName();
    }
    File c = new File(name);
    if (!c.exists()) {
        try {
            c.createNewFile();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    DataPackage intent1 = new DataPackage();
    intent1.setName(name);
    intent1.setTotal(0);
    intent1.setDone(0);
    intent1.setId(startId);
    intent1.setP1(0);
    intent1.setCompleted(false);
    hash1.put(startId, intent1);
    mBuilder = new NotificationCompat.Builder(this);
    Intent notificationIntent = new Intent(this, MainActivity.class);
    notificationIntent.putExtra("openprocesses", true);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
    mBuilder.setContentIntent(pendingIntent);
    mBuilder.setContentTitle(getResources().getString(R.string.zipping))

            .setSmallIcon(R.drawable.ic_doc_compressed);
    if (foreground) {
        startForeground(Integer.parseInt("789" + startId), mBuilder.build());
    }
    ArrayList<String> a = intent.getStringArrayListExtra("files");
    b.putInt("id", startId);
    b.putStringArrayList("files", a);
    b.putString("name", name);
    hash.put(startId, true);
    new Doback().execute(b);
    // If we get killed, after returning from here, restart
    return START_STICKY;
}

From source file:com.filemanager.free.services.ZipTask.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    Bundle b = new Bundle();
    zpath = PreferenceManager.getDefaultSharedPreferences(this).getString("zippath", "");
    mNotifyManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    String name = intent.getStringExtra("name");
    if ((zpath != null && zpath.length() != 0)) {
        if (zpath.endsWith("/")) {
            name = zpath + new File(name).getName();
        } else {//from  www.j a va  2 s .c om
            name = zpath + "/" + new File(name).getName();
        }
    }
    File c = new File(name);
    if (!c.exists()) {
        try {
            c.createNewFile();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    DataPackage intent1 = new DataPackage();
    intent1.setName(name);
    intent1.setTotal(0);
    intent1.setDone(0);
    intent1.setId(startId);
    intent1.setP1(0);
    intent1.setCompleted(false);
    hash1.put(startId, intent1);
    mBuilder = new NotificationCompat.Builder(this);
    Intent notificationIntent = new Intent(this, MainActivity.class);
    notificationIntent.putExtra("openprocesses", true);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
    mBuilder.setContentIntent(pendingIntent);
    mBuilder.setContentTitle(getResources().getString(R.string.zipping))

            .setSmallIcon(R.drawable.ic_doc_compressed);
    if (foreground) {
        startForeground(Integer.parseInt("789" + startId), mBuilder.build());
    }
    ArrayList<String> a = intent.getStringArrayListExtra("files");
    b.putInt("id", startId);
    b.putStringArrayList("files", a);
    b.putString("name", name);
    hash.put(startId, true);
    new Doback().execute(b);
    // If we get killed, after returning from here, restart
    return START_STICKY;
}

From source file:com.yanzhenjie.durban.DurbanActivity.java

private void initArgument(Intent intent) {
    mStatusColor = ContextCompat.getColor(this, R.color.durban_ColorPrimaryDark);
    mToolbarColor = ContextCompat.getColor(this, R.color.durban_ColorPrimary);
    mNavigationColor = ContextCompat.getColor(this, R.color.durban_ColorPrimaryBlack);

    mStatusColor = intent.getIntExtra(Durban.KEY_INPUT_STATUS_COLOR, mStatusColor);
    mToolbarColor = intent.getIntExtra(Durban.KEY_INPUT_TOOLBAR_COLOR, mToolbarColor);
    mNavigationColor = intent.getIntExtra(Durban.KEY_INPUT_NAVIGATION_COLOR, mNavigationColor);
    mTitle = intent.getStringExtra(Durban.KEY_INPUT_TITLE);
    if (TextUtils.isEmpty(mTitle))
        mTitle = getString(R.string.durban_title_crop);

    mGesture = intent.getIntExtra(Durban.KEY_INPUT_GESTURE, Durban.GESTURE_ALL);
    mAspectRatio = intent.getFloatArrayExtra(Durban.KEY_INPUT_ASPECT_RATIO);
    if (mAspectRatio == null)
        mAspectRatio = new float[] { 0, 0 };
    mMaxWidthHeight = intent.getIntArrayExtra(Durban.KEY_INPUT_MAX_WIDTH_HEIGHT);
    if (mMaxWidthHeight == null)
        mMaxWidthHeight = new int[] { 500, 500 };

    //noinspection JavacQuirks
    int compressFormat = intent.getIntExtra(Durban.KEY_INPUT_COMPRESS_FORMAT, 0);
    mCompressFormat = compressFormat == Durban.COMPRESS_PNG ? Bitmap.CompressFormat.PNG
            : Bitmap.CompressFormat.JPEG;
    mCompressQuality = intent.getIntExtra(Durban.KEY_INPUT_COMPRESS_QUALITY, 90);

    mOutputDirectory = intent.getStringExtra(Durban.KEY_INPUT_DIRECTORY);
    if (TextUtils.isEmpty(mOutputDirectory))
        mOutputDirectory = getFilesDir().getAbsolutePath();
    mInputPathList = intent.getStringArrayListExtra(Durban.KEY_INPUT_PATH_ARRAY);

    mController = intent.getParcelableExtra(Durban.KEY_INPUT_CONTROLLER);
    if (mController == null)
        mController = Controller.newBuilder().build();

    mOutputPathList = new ArrayList<>();
}

From source file:com.android.dialer.DialtactsFragment.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == ACTIVITY_REQUEST_CODE_VOICE_SEARCH) {
        if (resultCode == getActivity().RESULT_OK) {
            final ArrayList<String> matches = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
            if (matches.size() > 0) {
                final String match = matches.get(0);
                mVoiceSearchQuery = match;
            } else {
                Log.e(TAG, "Voice search - nothing heard");
            }/*from www .  j  av  a  2 s.c  o  m*/
        } else {
            Log.e(TAG, "Voice search failed");
        }
    }
    super.onActivityResult(requestCode, resultCode, data);
}

From source file:org.numixproject.hermes.activity.ConversationActivity.java

/**
 * On activity result// w ww. jav a  2  s  .c  om
 */
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode != RESULT_OK) {
        // ignore other result codes
        return;
    }

    switch (requestCode) {
    case REQUEST_CODE_SPEECH:
        ArrayList<String> matches = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
        if (matches.size() > 0) {
            input.setText(matches.get(0));
        }
        break;
    case REQUEST_CODE_JOIN:
        addRecentRoom(data.getExtras().getString("channel"));
        joinChannelBuffer = data.getExtras().getString("channel");
        final Handler handler2 = new Handler();
        handler2.postDelayed(new Runnable() {
            @Override
            public void run() {
                refreshActivity();
            }
        }, 100);
        break;
    case REQUEST_CODE_USERS:
        Intent intent = new Intent(this, UserActivity.class);
        intent.putExtra(Extra.USER, data.getStringExtra(Extra.USER));
        startActivityForResult(intent, REQUEST_CODE_USER);
        break;
    case REQUEST_CODE_NICK_COMPLETION:
        insertNickCompletion((AutoCompleteTextView) findViewById(R.id.input),
                data.getExtras().getString(Extra.USER));
        break;
    case REQUEST_CODE_USER:
        final int actionId = data.getExtras().getInt(Extra.ACTION);
        final String nickname = data.getExtras().getString(Extra.USER);
        final IRCConnection connection = binder.getService().getConnection(server.getId());
        final String conversation = server.getSelectedConversation();
        final Handler handler = new Handler();

        // XXX: Implement me - The action should be handled after onResume()
        //                     to catch the broadcasts... now we just wait a second
        // Yes .. that's very ugly - we need some kind of queue that is handled after onResume()

        new Thread() {
            @Override
            public void run() {
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    // Do nothing
                }

                String nicknameWithoutPrefix = nickname;

                while (nicknameWithoutPrefix.startsWith("@") || nicknameWithoutPrefix.startsWith("+")
                        || nicknameWithoutPrefix.startsWith(".") || nicknameWithoutPrefix.startsWith("%")) {
                    // Strip prefix(es) now
                    nicknameWithoutPrefix = nicknameWithoutPrefix.substring(1);
                }

                switch (actionId) {
                case User.ACTION_REPLY:
                    final String replyText = nicknameWithoutPrefix + ": ";
                    handler.post(new Runnable() {
                        @Override
                        public void run() {
                            input.setText(replyText);
                            input.setSelection(replyText.length());
                        }
                    });
                    break;
                case User.ACTION_QUERY:
                    Conversation query = server.getConversation(nicknameWithoutPrefix);
                    if (query == null) {
                        // Open a query if there's none yet
                        query = new Query(nicknameWithoutPrefix);
                        query.setHistorySize(binder.getService().getSettings().getHistorySize());
                        server.addConversation(query);

                        Intent intent = Broadcast.createConversationIntent(Broadcast.CONVERSATION_NEW,
                                server.getId(), nicknameWithoutPrefix);
                        binder.getService().sendBroadcast(intent);
                    }
                    break;
                case User.ACTION_WHOIS:
                    connection.whois(conversation, nicknameWithoutPrefix);
                    break;
                case User.ACTION_OP:
                    connection.op(conversation, nicknameWithoutPrefix);
                    break;
                case User.ACTION_DEOP:
                    connection.deOp(conversation, nicknameWithoutPrefix);
                    break;
                case User.ACTION_VOICE:
                    connection.voice(conversation, nicknameWithoutPrefix);
                    break;
                case User.ACTION_DEVOICE:
                    connection.deVoice(conversation, nicknameWithoutPrefix);
                    break;
                case User.ACTION_KICK:
                    connection.kick(conversation, nicknameWithoutPrefix);
                    break;
                case User.ACTION_BAN:
                    connection.ban(conversation, nicknameWithoutPrefix + "!*@*");
                    break;
                }
            }
        }.start();

        break;
    }
}

From source file:info.papdt.blacklight.ui.statuses.NewPostActivity.java

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

    // Image picked, decode
    if (requestCode == REQUEST_PICK_IMG && resultCode == RESULT_OK) {
        if (Build.VERSION.SDK_INT >= 19) {
            try {
                ParcelFileDescriptor parcelFileDescriptor = getContentResolver()
                        .openFileDescriptor(data.getData(), "r");
                FileDescriptor fileDescriptor = parcelFileDescriptor.getFileDescriptor();
                Bitmap image = BitmapFactory.decodeFileDescriptor(fileDescriptor);
                parcelFileDescriptor.close();
                addPicture(image, null);
            } catch (FileNotFoundException e) {
                e.printStackTrace();//from ww  w . ja  v  a 2s.c  o  m
            } catch (IOException e) {
                e.printStackTrace();
            }
        } else {
            Cursor cursor = getContentResolver().query(data.getData(),
                    new String[] { MediaStore.Images.Media.DATA }, null, null, null);
            cursor.moveToFirst();
            String filePath = cursor.getString(cursor.getColumnIndex(MediaStore.Images.Media.DATA));
            cursor.close();

            // Then decode
            addPicture(null, filePath);
        }
    } else if (requestCode == REQUEST_CAPTURE_PHOTO && resultCode == RESULT_OK) {
        addPicture(null, Utility.lastPicPath);
    } else if (resultCode == MultiPicturePicker.PICK_OK) {
        ArrayList<String> paths = data.getStringArrayListExtra("img");

        for (String path : paths) {
            addPicture(null, path);

            if (mBitmaps.size() >= 9) {
                break;
            }
        }
    }
}

From source file:com.fbartnitzek.tasteemall.MainActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    Log.v(LOG_TAG, "onActivityResult, hashCode=" + this.hashCode() + ", " + "requestCode = [" + requestCode
            + "], resultCode = [" + resultCode + "], data = [" + data + "]");

    if (requestCode == REQUEST_EXPORT_DIR_CODE
            || requestCode == REQUEST_IMPORT_FILES_CODE && resultCode == AppCompatActivity.RESULT_OK) {
        Uri uri;//from   w  ww .  j  a v  a  2  s .c  o m
        if (data.getBooleanExtra(FilePickerActivity.EXTRA_ALLOW_MULTIPLE, false)) {

            List<File> files = new ArrayList<>();
            // For JellyBean and above
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                ClipData clip = data.getClipData();

                if (clip != null) {
                    for (int i = 0; i < clip.getItemCount(); i++) {
                        uri = clip.getItemAt(i).getUri();
                        //                            Log.v(LOG_TAG, "onActivityResult, uri=" + uri + ", hashCode=" + this.hashCode() + ", " + "requestCode = [" + requestCode + "], resultCode = [" + resultCode + "], data = [" + data + "]");
                        files.add(new File(uri.getPath()));
                        // Do something with the URI
                    }
                }
                // For Ice Cream Sandwich
            } else {
                ArrayList<String> paths = data.getStringArrayListExtra(FilePickerActivity.EXTRA_PATHS);

                if (paths != null) {
                    for (String path : paths) {
                        uri = Uri.parse(path); // TODO: might be useless conversion...
                        //                            Log.v(LOG_TAG, "onActivityResult, uri=" + uri + ", hashCode=" + this.hashCode() + ", " + "requestCode = [" + requestCode + "], resultCode = [" + resultCode + "], data = [" + data + "]");
                        files.add(new File(uri.getPath()));
                    }
                }
            }

            if (!files.isEmpty() && requestCode == REQUEST_IMPORT_FILES_CODE) {

                // TODO: refactor afterwards without mFiles
                // new ImportFilesTask(MPA.this, MPA.this).execute(files.toArray(new File[files.size()]));

                mFiles = files;
                AlertDialog.Builder builder = new AlertDialog.Builder(this);
                builder.setMessage("which import shall be used?")
                        .setPositiveButton("class-based", new DialogInterface.OnClickListener() {

                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                new ImportFilesTask(MainActivity.this, MainActivity.this)
                                        .execute(mFiles.toArray(new File[mFiles.size()]));
                                mFiles = null;
                            }
                        })
                        //                            .setNegativeButton("old", new DialogInterface.OnClickListener() {
                        //                                @Override
                        //                                public void onClick(DialogInterface dialog, int which) {
                        //                                    new ImportFilesOldFormatTask(MainActivity.this, MainActivity.this)
                        //                                            .execute(mFiles.toArray(new File[mFiles.size()]));
                        //                                    mFiles = null;
                        //                                }
                        //                            });
                        .setNegativeButton("all-in-1", new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {

                                // multiple all-in-1-files?
                                new ImportAllInOneFileTask(MainActivity.this, MainActivity.this)
                                        .execute(mFiles.get(0));
                                mFiles = null;
                                // to get all easier:
                                // either all ids are known or lots of parallel stuff...
                                // dialog with warning!
                                // task won't help => needs Dialog everywhere... => Task
                                // merge is to complicated for now :-p

                            }
                        });
                builder.show();
            }

        } else {
            //                Log.v(LOG_TAG, "onActivityResult - single file, hashCode=" + this.hashCode() + ", " + "requestCode = [" + requestCode + "], resultCode = [" + resultCode + "], data = [" + data + "]");
            uri = data.getData();
            // Do something with the URI
            if (uri != null && requestCode == REQUEST_EXPORT_DIR_CODE) {
                //somehow it returned a filepath (confusing use of multiple flag...
                new ExportToDirTask(this, this).execute(new File(uri.getPath()));
            }

        }

    } else if (requestCode == REQUEST_EDIT_PRODUCER_GEOCODE && resultCode == AppCompatActivity.RESULT_OK) {

        if (mProducerLocationUris == null) {
            Log.e(LOG_TAG, "onActivityResult mProducerLocationUris == null! - should never happen...");
            return;
        }

        if (mProducerLocationUris.isEmpty()) {
            if (mReviewLocationUris != null && !mReviewLocationUris.isEmpty()) {
                showReviewLocationGeocodeDialog(true);
            } else {
                Toast.makeText(MainActivity.this, "all geocoding done", Toast.LENGTH_SHORT).show();
                restartCurrentFragmentLoader();
            }
        } else {
            showProducerGeocodeDialog(true);
        }

    } else if (requestCode == REQUEST_EDIT_REVIEW_LOCATION_GEOCODE
            && resultCode == AppCompatActivity.RESULT_OK) {
        if (mReviewLocationUris == null) {
            Log.e(LOG_TAG, "onActivityResult mReviewLocationUris == null! - should never happen");
            return;
        }

        if (mReviewLocationUris.isEmpty()) {
            Toast.makeText(MainActivity.this, "all geocoding done", Toast.LENGTH_SHORT).show();
            restartCurrentFragmentLoader();
        } else {
            showReviewLocationGeocodeDialog(true);
        }
    } else if (requestCode == ADD_REVIEW_REQUEST && resultCode == Activity.RESULT_OK && data != null) {
        // TODO bugfix: refresh current pager
        startActivity(new Intent(this, ShowReviewActivity.class).setData(data.getData()));
    }

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