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.MainActivity.java

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

    if (resultCode == RESULT_OK) {

        if (requestCode == REQUEST_CHANGE_SETTINGS) {
            finish();/* w  w w  .  j a va  2 s  .  co  m*/
            startActivity(new Intent(this, MainActivity.class));
        } else if (requestCode == REQUEST_ADD_CONTACT) {

            String username = data.getStringExtra(ContactsPickerActivity.EXTRA_RESULT_USERNAME);
            long providerId = data.getLongExtra(ContactsPickerActivity.EXTRA_RESULT_PROVIDER, -1);
            long accountId = data.getLongExtra(ContactsPickerActivity.EXTRA_RESULT_ACCOUNT, -1);

            startChat(providerId, accountId, username, false, false);

        } else if (requestCode == REQUEST_CHOOSE_CONTACT) {
            String username = data.getStringExtra(ContactsPickerActivity.EXTRA_RESULT_USERNAME);

            if (username != null) {
                long providerId = data.getLongExtra(ContactsPickerActivity.EXTRA_RESULT_PROVIDER, -1);
                long accountId = data.getLongExtra(ContactsPickerActivity.EXTRA_RESULT_ACCOUNT, -1);

                startChat(providerId, accountId, username, true, true);
            } else {

                ArrayList<String> users = data
                        .getStringArrayListExtra(ContactsPickerActivity.EXTRA_RESULT_USERNAMES);
                if (users != null) {
                    //start group and do invite here
                    startGroupChat(users);
                }

            }
        } else if (requestCode == ConversationDetailActivity.REQUEST_TAKE_PICTURE) {
            if (mLastPhoto != null)
                importPhoto();

        } else if (requestCode == OnboardingManager.REQUEST_SCAN) {

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

                try {

                    String address = null;

                    if (resultScan.startsWith("xmpp:")) {
                        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);

                    } else {
                        //parse each string and if they are for a new user then add the user
                        String[] parts = OnboardingManager.decodeInviteLink(resultScan);
                        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);
                    }

                    if (address != null)
                        startChat(mApp.getDefaultProviderId(), mApp.getDefaultAccountId(), address, false,
                                false);

                    //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);
                }
            }
        }
    }
}

From source file:me.tb.player.SkeletonActivity.java

public void startTheGame(Intent data) {

    if (data.getStringExtra("message").equals("saved")) {
        TurnBasedMatch match = data.getParcelableExtra(Multiplayer.EXTRA_TURN_BASED_MATCH);

        if (match != null) {
            updateMatch(match);//from ww w  .j ava2  s .c o  m
        }
    } else {

        // get the invitee list
        final ArrayList<String> invitees = data.getStringArrayListExtra(Games.EXTRA_PLAYER_IDS);

        // get automatch criteria
        Bundle autoMatchCriteria = null;

        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).build();

        // Start the match
        Games.TurnBasedMultiplayer.createMatch(mGoogleApiClient, tbmc)
                .setResultCallback(new ResultCallback<TurnBasedMultiplayer.InitiateMatchResult>() {
                    @Override
                    public void onResult(TurnBasedMultiplayer.InitiateMatchResult result) {
                        processResult(result);
                    }
                });
        showSpinner();
    }
}

From source file:com.brandroidtools.filemanager.activities.NavigationActivity.java

/**
 * Method that verifies the intent passed to the activity, and checks
 * if a request is made like Search./*  w  ww .j  av  a2 s  . co m*/
 *
 * @param intent The intent to check
 * @hide
 */
void checkIntent(Intent intent) {
    //Search action
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        Intent searchIntent = new Intent(this, SearchActivity.class);
        searchIntent.setAction(Intent.ACTION_SEARCH);
        //- SearchActivity.EXTRA_SEARCH_DIRECTORY
        searchIntent.putExtra(SearchActivity.EXTRA_SEARCH_DIRECTORY,
                getCurrentNavigationFragment().getCurrentDir());
        //- SearchManager.APP_DATA
        if (intent.getBundleExtra(SearchManager.APP_DATA) != null) {
            Bundle bundle = new Bundle();
            bundle.putAll(intent.getBundleExtra(SearchManager.APP_DATA));
            searchIntent.putExtra(SearchManager.APP_DATA, bundle);
        }
        //-- SearchManager.QUERY
        String query = intent.getStringExtra(SearchManager.QUERY);
        if (query != null) {
            searchIntent.putExtra(SearchManager.QUERY, query);
        }
        //- android.speech.RecognizerIntent.EXTRA_RESULTS
        ArrayList<String> extraResults = intent
                .getStringArrayListExtra(android.speech.RecognizerIntent.EXTRA_RESULTS);
        if (extraResults != null) {
            searchIntent.putStringArrayListExtra(android.speech.RecognizerIntent.EXTRA_RESULTS, extraResults);
        }
        startActivityForResult(searchIntent, INTENT_REQUEST_SEARCH);
        return;
    }

    // Navigate to the requested path
    String navigateTo = intent.getStringExtra(EXTRA_NAVIGATE_TO);
    if (navigateTo != null && navigateTo.length() >= 0) {
        getCurrentNavigationFragment().changeCurrentDir(navigateTo);
    }
}

From source file:it.feio.android.omninotes.DetailFragment.java

private void handleIntents() {
    Intent i = mainActivity.getIntent();

    if (IntentChecker.checkAction(i, Constants.ACTION_MERGE)) {
        noteOriginal = new Note();
        note = new Note(noteOriginal);
        noteTmp = getArguments().getParcelable(Constants.INTENT_NOTE);
        if (i.getStringArrayListExtra("merged_notes") != null) {
            mergedNotesIds = i.getStringArrayListExtra("merged_notes");
        }/*from  w  ww .  j  a v a 2  s  .  co m*/
    }

    // Action called from home shortcut
    if (IntentChecker.checkAction(i, Constants.ACTION_SHORTCUT, Constants.ACTION_NOTIFICATION_CLICK)) {
        afterSavedReturnsToList = false;
        noteOriginal = DbHelper.getInstance().getNote(i.getLongExtra(Constants.INTENT_KEY, 0));
        // Checks if the note pointed from the shortcut has been deleted
        try {
            note = new Note(noteOriginal);
            noteTmp = new Note(noteOriginal);
        } catch (NullPointerException e) {
            mainActivity.showToast(getText(R.string.shortcut_note_deleted), Toast.LENGTH_LONG);
            mainActivity.finish();
        }
    }

    // Check if is launched from a widget
    if (IntentChecker.checkAction(i, Constants.ACTION_WIDGET, Constants.ACTION_TAKE_PHOTO)) {

        afterSavedReturnsToList = false;
        showKeyboard = true;

        //  with tags to set tag
        if (i.hasExtra(Constants.INTENT_WIDGET)) {
            String widgetId = i.getExtras().get(Constants.INTENT_WIDGET).toString();
            if (widgetId != null) {
                String sqlCondition = prefs.getString(Constants.PREF_WIDGET_PREFIX + widgetId, "");
                String categoryId = TextHelper.checkIntentCategory(sqlCondition);
                if (categoryId != null) {
                    Category category;
                    try {
                        category = DbHelper.getInstance().getCategory(Long.parseLong(categoryId));
                        noteTmp = new Note();
                        noteTmp.setCategory(category);
                    } catch (NumberFormatException e) {
                        Log.e(Constants.TAG, "Category with not-numeric value!", e);
                    }
                }
            }
        }

        // Sub-action is to take a photo
        if (IntentChecker.checkAction(i, Constants.ACTION_TAKE_PHOTO)) {
            takePhoto();
        }
    }

    /**
     * Handles third party apps requests of sharing
     */
    if (IntentChecker.checkAction(i, Intent.ACTION_SEND, Intent.ACTION_SEND_MULTIPLE,
            Constants.INTENT_GOOGLE_NOW) && i.getType() != null) {

        afterSavedReturnsToList = false;

        if (noteTmp == null)
            noteTmp = new Note();

        // Text title
        String title = i.getStringExtra(Intent.EXTRA_SUBJECT);
        if (title != null) {
            noteTmp.setTitle(title);
        }

        // Text content
        String content = i.getStringExtra(Intent.EXTRA_TEXT);
        if (content != null) {
            noteTmp.setContent(content);
        }

        // Single attachment data
        Uri uri = i.getParcelableExtra(Intent.EXTRA_STREAM);
        // Due to the fact that Google Now passes intent as text but with
        // audio recording attached the case must be handled in specific way
        if (uri != null && !Constants.INTENT_GOOGLE_NOW.equals(i.getAction())) {
            String name = FileHelper.getNameFromUri(mainActivity, uri);
            AttachmentTask task = new AttachmentTask(this, uri, name, this);
            task.execute();
        }

        // Multiple attachment data
        ArrayList<Uri> uris = i.getParcelableArrayListExtra(Intent.EXTRA_STREAM);
        if (uris != null) {
            for (Uri uriSingle : uris) {
                String name = FileHelper.getNameFromUri(mainActivity, uriSingle);
                AttachmentTask task = new AttachmentTask(this, uriSingle, name, this);
                task.execute();
            }
        }

        //         i.setAction(null);
    }

    if (IntentChecker.checkAction(i, Intent.ACTION_MAIN, Constants.ACTION_WIDGET_SHOW_LIST)) {
        showKeyboard = true;
    }

}

From source file:com.dycody.android.idealnote.DetailFragment.java

private void handleIntents() {
    Intent i = mainActivity.getIntent();

    if (IntentChecker.checkAction(i, Constants.ACTION_MERGE)) {
        noteOriginal = new Note();
        note = new Note(noteOriginal);
        noteTmp = getArguments().getParcelable(Constants.INTENT_NOTE);
        if (i.getStringArrayListExtra("merged_notes") != null) {
            mergedNotesIds = i.getStringArrayListExtra("merged_notes");
        }//from w ww  .j  av a 2  s  .co  m
    }

    // Action called from home shortcut
    if (IntentChecker.checkAction(i, Constants.ACTION_SHORTCUT, Constants.ACTION_NOTIFICATION_CLICK)) {
        afterSavedReturnsToList = false;
        noteOriginal = DbHelper.getInstance().getNote(i.getLongExtra(Constants.INTENT_KEY, 0));
        // Checks if the note pointed from the shortcut has been deleted
        try {
            note = new Note(noteOriginal);
            noteTmp = new Note(noteOriginal);
        } catch (NullPointerException e) {
            mainActivity.showToast(getText(R.string.shortcut_note_deleted), Toast.LENGTH_LONG);
            mainActivity.finish();
        }
    }

    // Check if is launched from a widget
    if (IntentChecker.checkAction(i, Constants.ACTION_WIDGET, Constants.ACTION_TAKE_PHOTO)) {

        afterSavedReturnsToList = false;
        showKeyboard = true;

        //  with tags to set tag
        if (i.hasExtra(Constants.INTENT_WIDGET)) {
            String widgetId = i.getExtras().get(Constants.INTENT_WIDGET).toString();
            if (widgetId != null) {
                String sqlCondition = prefs.getString(Constants.PREF_WIDGET_PREFIX + widgetId, "");
                String categoryId = TextHelper.checkIntentCategory(sqlCondition);
                if (categoryId != null) {
                    Category category;
                    try {
                        category = DbHelper.getInstance().getCategory(Long.parseLong(categoryId));
                        noteTmp = new Note();
                        noteTmp.setCategory(category);
                    } catch (NumberFormatException e) {
                        Log.e(Constants.TAG, "Category with not-numeric value!", e);
                    }
                }
            }
        }

        // Sub-action is to take a photo
        if (IntentChecker.checkAction(i, Constants.ACTION_TAKE_PHOTO)) {
            takePhoto();
        }
    }

    /**
     * Handles third party apps requests of sharing
     */
    if (IntentChecker.checkAction(i, Intent.ACTION_SEND, Intent.ACTION_SEND_MULTIPLE,
            Constants.INTENT_GOOGLE_NOW) && i.getType() != null) {

        afterSavedReturnsToList = false;

        if (noteTmp == null)
            noteTmp = new Note();

        // Text title
        String title = i.getStringExtra(Intent.EXTRA_SUBJECT);
        if (title != null) {
            noteTmp.setTitle(title);
        }

        // Text content
        String content = i.getStringExtra(Intent.EXTRA_TEXT);
        if (content != null) {
            noteTmp.setContent(content);
        }

        // Single attachment data
        Uri uri = i.getParcelableExtra(Intent.EXTRA_STREAM);
        // Due to the fact that Google Now passes intent as text but with
        // audio recording attached the case must be handled in specific way
        if (uri != null && !Constants.INTENT_GOOGLE_NOW.equals(i.getAction())) {
            String name = FileHelper.getNameFromUri(mainActivity, uri);
            new AttachmentTask(this, uri, name, this).execute();
        }

        // Multiple attachment data
        ArrayList<Uri> uris = i.getParcelableArrayListExtra(Intent.EXTRA_STREAM);
        if (uris != null) {
            for (Uri uriSingle : uris) {
                String name = FileHelper.getNameFromUri(mainActivity, uriSingle);
                new AttachmentTask(this, uriSingle, name, this).execute();
            }
        }
    }

    if (IntentChecker.checkAction(i, Intent.ACTION_MAIN, Constants.ACTION_WIDGET_SHOW_LIST,
            Constants.ACTION_SHORTCUT_WIDGET, Constants.ACTION_WIDGET)) {
        showKeyboard = true;
    }

    i.setAction(null);
}

From source file:org.uguess.android.sysinfo.ProcessManager.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    Activity ctx = getActivity();//w  ww.  j a  v a  2s. c  om

    if (requestCode == 1 && data != null) {
        Util.updateIntOption(data, ctx, PSTORE_PROCESSMANAGER, PREF_KEY_REFRESH_INTERVAL, REFRESH_LOW);
        Util.updateIntOption(data, ctx, PSTORE_PROCESSMANAGER, PREF_KEY_SORT_ORDER_TYPE, ORDER_TYPE_NAME);
        Util.updateIntOption(data, ctx, PSTORE_PROCESSMANAGER, PREF_KEY_SORT_DIRECTION, ORDER_ASC);
        Util.updateIntOption(data, ctx, PSTORE_PROCESSMANAGER, PREF_KEY_IGNORE_ACTION, IGNORE_ACTION_HIDDEN);
        Util.updateIntOption(data, ctx, PSTORE_PROCESSMANAGER, PREF_KEY_DEFAULT_TAP_ACTION, ACTION_MENU);

        Util.updateBooleanOption(data, ctx, PSTORE_PROCESSMANAGER, PREF_KEY_SHOW_MEM);
        Util.updateBooleanOption(data, ctx, PSTORE_PROCESSMANAGER, PREF_KEY_SHOW_CPU);
        Util.updateBooleanOption(data, ctx, PSTORE_PROCESSMANAGER, PREF_KEY_SHOW_SYS_PROC);
        Util.updateBooleanOption(data, ctx, PSTORE_PROCESSMANAGER, PREF_KEY_SHOW_KILL_WARN);

        ArrayList<String> list = data.getStringArrayListExtra(PREF_KEY_IGNORE_LIST);

        setIgnoreList(list);

        ignoreList.clear();

        if (list != null) {
            ignoreList.addAll(list);
        }
    }
}

From source file:org.botlibre.sdk.activity.ChatActivity.java

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

    switch (requestCode) {
    case CAPTURE_IMAGE: {

        if (resultCode == RESULT_OK) {
            //TODO Make camera intent stop app from reseting
            //Uri photoUri = data.getData();
            //Do what we like with the photo - send to bot, etc

        } else if (resultCode == RESULT_CANCELED) {
            textView.setText("Cancelled");
            submitChat();/*from www .j  ava  2s .c  om*/
        }

        break;
    }
    case CAPTURE_VIDEO: {
        if (resultCode == RESULT_OK) {
            Uri videoUri = data.getData();
            //Do what we would like with the video

        } else if (resultCode == RESULT_CANCELED) {
            textView.setText("Cancelled");
            submitChat();
        }
        break;
    }
    case RESULT_SPEECH: {
        if (resultCode == RESULT_OK && data != null) {

            ArrayList<String> text = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);

            textView.setText(text.get(0));
            submitChat();
        }
        break;
    }
    }
    IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
    if (scanResult != null) {
        textView.setText("lookup " + scanResult.getContents());
        submitChat();
        if (scanResult.getContents().startsWith("http")) {
            Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(scanResult.getContents()));
            startActivity(intent);
        }
    }
}

From source file:onion.chat.MainActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode != RESULT_OK)
        return;/*from   w  w  w .  j a  va 2  s.  c o m*/
    if (requestCode == REQUEST_QR) {
        Bitmap bitmap = (Bitmap) data.getExtras().get("data");
        int width = bitmap.getWidth(), height = bitmap.getHeight();
        int[] pixels = new int[width * height];
        bitmap.getPixels(pixels, 0, width, 0, 0, width, height);
        bitmap.recycle();
        RGBLuminanceSource source = new RGBLuminanceSource(width, height, pixels);
        BinaryBitmap bBitmap = new BinaryBitmap(new HybridBinarizer(source));
        MultiFormatReader reader = new MultiFormatReader();
        try {
            Result result = reader.decode(bBitmap);
            String str = result.getText();
            Log.i("ID", str);

            String[] tokens = str.split(" ", 3);

            if (tokens.length < 2 || !tokens[0].equals("Its Ur's")) {
                snack(getString(R.string.qr_invalid));
                return;
            }

            String id = tokens[1].toLowerCase();

            if (id.length() != 16) {
                snack(getString(R.string.qr_invalid));
                return;
            }

            if (db.hasContact(id)) {
                snack(getString(R.string.contact_already_added));
                return;
            }

            String name = "";
            if (tokens.length > 2) {
                name = tokens[2];
            }

            addContact(id, name);

            return;

        } catch (Exception ex) {
            snack(getString(R.string.qr_invalid));
            ex.printStackTrace();
        }
    } else if (requestCode == VOICE_RECOGNITION_REQUEST_CODE) {
        if (resultCode == RESULT_OK) {
            ArrayList<String> textMatchList = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
            String[] textTyped = new String[textMatchList.size()];
            String typeText = "";
            for (int i = 0; i < textMatchList.size(); i++) {
                textTyped[i] = textMatchList.get(i);
                typeText += textTyped[i];
            }
            if (!textMatchList.isEmpty()) {

                if (textMatchList.get(0).contains("open") || textMatchList.get(0).contains("OPEN")) {
                    String contName = "";
                    if (typeText.contains("open chat")) {
                        if (textMatchList.size() >= 2) {
                            contName = textMatchList.get(2);
                        }
                        if (contName != "") {
                            startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("chat:" + contName),
                                    getApplicationContext(), ChatActivity.class));
                        }
                    }
                    listen();
                } else if (textMatchList.get(0).contains("password")
                        || textMatchList.get(0).contains("PASSWORD")) {
                    String password = "password";

                    if (textMatchList.size() >= 2) {

                        password = textMatchList.get(0).replaceFirst("password ", "");

                    } else if (textMatchList.size() >= 1) {

                        password = textMatchList.get(0).replaceFirst("password ", "");

                    }
                    db.setPassword(password);
                    update();
                    String toSpeak = "password changed successfully to " + password;
                    Toast.makeText(getApplicationContext(), toSpeak, Toast.LENGTH_SHORT).show();
                    listen();

                } else if (textMatchList.get(0).contains("change") || textMatchList.get(0).contains("CHANGE")) {
                    String name = "";
                    if (textMatchList.size() >= 2) {
                        name = textMatchList.get(2);
                    }
                    db.setName(name);
                    update();
                    snack(getString(R.string.snack_alias_changed));
                    String toSpeak = "Alias changed to " + name;
                    Toast.makeText(getApplicationContext(), toSpeak, Toast.LENGTH_SHORT).show();
                    t1.speak(toSpeak, TextToSpeech.QUEUE_FLUSH, null);
                    listen();
                } else if (textMatchList.get(0).contains("tell") || textMatchList.get(0).contains("tell")) {
                    String id1 = "";
                    id1 = (tor.getID());
                    Toast.makeText(getApplicationContext(), id1, Toast.LENGTH_SHORT).show();
                    //t1.speak(id1, TextToSpeech.QUEUE_FLUSH, null);
                    listen();
                } else if (textMatchList.get(0).contains("enter") || textMatchList.get(0).contains("ENTER")) {
                    String id1 = "Yet to come";
                    Toast.makeText(getApplicationContext(), id1, Toast.LENGTH_SHORT).show();
                    //t1.speak(id1, TextToSpeech.QUEUE_FLUSH, null);
                    listen();
                } else if (textMatchList.get(0).contains("HELP") || textMatchList.get(0).contains("help")) {
                    String toSpeak = "Voice Commands that can be used are 1 Open chat with contact name 2 change with alias name 3 tell";
                    Toast.makeText(getApplicationContext(), toSpeak, Toast.LENGTH_SHORT).show();
                    t1.speak(toSpeak, TextToSpeech.QUEUE_FLUSH, null);
                    listen();
                }

                else if (textMatchList.get(0).contains("close") || textMatchList.get(0).contains("CLOSE")) {
                    String toSpeak = "Closing Voice command";
                    Toast.makeText(getApplicationContext(), toSpeak, Toast.LENGTH_SHORT).show();
                    t1.speak(toSpeak, TextToSpeech.QUEUE_FLUSH, null);
                }

                else {
                    // poString
                    String toSpeak = "I Can't Understand";
                    Toast.makeText(getApplicationContext(), toSpeak, Toast.LENGTH_SHORT).show();
                    // t1.speak(toSpeak, TextToSpeech.QUEUE_FLUSH, null);
                    listen();
                }

            }
            //Result code for various error.
        } else if (resultCode == RecognizerIntent.RESULT_AUDIO_ERROR) {

            String toSpeak = "Audio Error";
            Toast.makeText(getApplicationContext(), toSpeak, Toast.LENGTH_SHORT).show();
            t1.speak(toSpeak, TextToSpeech.QUEUE_FLUSH, null);
        } else if (resultCode == RecognizerIntent.RESULT_CLIENT_ERROR) {

            String toSpeak = "Client Error";
            Toast.makeText(getApplicationContext(), toSpeak, Toast.LENGTH_SHORT).show();
            t1.speak(toSpeak, TextToSpeech.QUEUE_FLUSH, null);
        } else if (resultCode == RecognizerIntent.RESULT_NETWORK_ERROR) {

            String toSpeak = "Network Error";
            Toast.makeText(getApplicationContext(), toSpeak, Toast.LENGTH_SHORT).show();
            t1.speak(toSpeak, TextToSpeech.QUEUE_FLUSH, null);
        } else if (resultCode == RecognizerIntent.RESULT_NO_MATCH) {

            String toSpeak = "No Match";
            Toast.makeText(getApplicationContext(), toSpeak, Toast.LENGTH_SHORT).show();
            t1.speak(toSpeak, TextToSpeech.QUEUE_FLUSH, null);
        } else if (resultCode == RecognizerIntent.RESULT_SERVER_ERROR) {

            String toSpeak = "Server Error";
            Toast.makeText(getApplicationContext(), toSpeak, Toast.LENGTH_SHORT).show();
            t1.speak(toSpeak, TextToSpeech.QUEUE_FLUSH, null);
        }

    }

}

From source file:net.xisberto.phonetodesktop.network.GoogleTasksService.java

@Override
protected void onHandleIntent(Intent intent) {
    if (intent != null) {
        final String action = intent.getAction();
        Utils.log("onHandleIntent " + intent.getAction());
        long[] tasks_ids;
        try {//from   w  ww. java  2s  . c o  m
            if (action.equals(Utils.ACTION_PROCESS_TASK)) {
                long task_id = intent.getLongExtra(Utils.EXTRA_TASK_ID, -1);
                LocalTask task = DatabaseHelper.getInstance(this).getTask(task_id);
                final Intent result = new Intent(Utils.ACTION_RESULT_PROCESS_TASK);
                result.putExtra(Utils.EXTRA_TASK_ID, task.getLocalId());
                if (isOnline()) {
                    processOptions(task);
                    task.persistBlocking(new PersistCallback() {
                        @Override
                        public void run() {
                            if (cache_unshorten != null) {
                                result.putExtra(Utils.EXTRA_CACHE_UNSHORTEN, cache_unshorten);
                            }
                            if (cache_titles != null) {
                                result.putExtra(Utils.EXTRA_CACHE_TITLES, cache_titles);
                            }
                            LocalBroadcastManager.getInstance(GoogleTasksService.this).sendBroadcast(result);
                        }
                    });
                } else {
                    tasks_ids = intent.getLongArrayExtra(Utils.EXTRA_TASKS_IDS);
                    revertTaskToReady(tasks_ids);
                    LocalBroadcastManager.getInstance(this).sendBroadcast(result);
                }
            } else if (action.equals(Utils.ACTION_SEND_TASKS)) {
                if (isOnline()) {

                    tasks_ids = intent.getLongArrayExtra(Utils.EXTRA_TASKS_IDS);

                    if (tasks_ids.length == 1) {
                        DatabaseHelper databaseHelper = DatabaseHelper.getInstance(this);
                        LocalTask task = databaseHelper.getTask(tasks_ids[0]);
                        handleActionSend(task);
                    } else {
                        handleActionSendMultiple(tasks_ids);
                    }

                    stopForeground(true);
                } else {
                    tasks_ids = intent.getLongArrayExtra(Utils.EXTRA_TASKS_IDS);
                    revertTaskToReady(tasks_ids);
                    ((NotificationManager) getSystemService(NOTIFICATION_SERVICE)).notify(
                            NOTIFICATION_SEND_LATER, buildNotification(NOTIFICATION_SEND_LATER).build());
                }
            } else if (action.equals(Utils.ACTION_LIST_TASKS)) {
                handleActionList();
            } else if (action.equals(Utils.ACTION_REMOVE_TASKS)) {
                handleActionRemove(intent.getStringArrayListExtra(Utils.EXTRA_TASKS_IDS));
            }
        } catch (UserRecoverableAuthIOException userRecoverableException) {
            Utils.log(Log.getStackTraceString(userRecoverableException));
            stopForeground(true);
            tasks_ids = intent.getLongArrayExtra(Utils.EXTRA_TASKS_IDS);
            revertTaskToReady(tasks_ids);
            ((NotificationManager) getSystemService(NOTIFICATION_SERVICE)).notify(NOTIFICATION_NEED_AUTHORIZE,
                    buildNotification(NOTIFICATION_NEED_AUTHORIZE).build());
        } catch (IOException ioException) {
            Utils.log(Log.getStackTraceString(ioException));
            if (action.equals(Utils.ACTION_SEND_TASKS)) {
                tasks_ids = intent.getLongArrayExtra(Utils.EXTRA_TASKS_IDS);
                stopForeground(true);
                revertTaskToReady(tasks_ids);
                ((NotificationManager) getSystemService(NOTIFICATION_SERVICE)).notify(NOTIFICATION_ERROR,
                        buildNotification(NOTIFICATION_ERROR).build());
            } else {
                Intent broadcast = new Intent(Utils.ACTION_LIST_TASKS);
                broadcast.putExtra(Utils.EXTRA_ERROR_TEXT, getString(R.string.txt_error_list));
                LocalBroadcastManager.getInstance(this).sendBroadcast(broadcast);
            }
        } catch (NullPointerException npe) {
            tasks_ids = intent.getLongArrayExtra(Utils.EXTRA_TASKS_IDS);
            Utils.log(Log.getStackTraceString(npe));
            stopForeground(true);
            revertTaskToReady(tasks_ids);
            ((NotificationManager) getSystemService(NOTIFICATION_SERVICE)).notify(NOTIFICATION_NEED_AUTHORIZE,
                    buildNotification(NOTIFICATION_NEED_AUTHORIZE).build());
        }
    }
}

From source file:com.igniva.filemanager.activities.MainActivity.java

@Override
public void onNewIntent(Intent i) {
    intent = i;//from w  ww .j a  v a  2  s .  com
    path = i.getStringExtra("path");
    if (path != null) {
        if (new File(path).isDirectory()) {
            Fragment f = getDFragment();
            if ((f.getClass().getName().contains("TabFragment"))) {
                Main m = ((Main) getFragment().getTab());
                m.loadlist(path, false, 0);
            } else
                goToMain(path);
        } else
            utils.openFile(new File(path), mainActivity);
    } else if (i.getStringArrayListExtra("failedOps") != null) {
        ArrayList<BaseFile> failedOps = i.getParcelableArrayListExtra("failedOps");
        if (failedOps != null) {
            mainActivityHelper.showFailedOperationDialog(failedOps, i.getBooleanExtra("move", false), this);
        }
    } else if ((openprocesses = i.getBooleanExtra("openprocesses", false))) {

        android.support.v4.app.FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
        transaction.replace(R.id.content_frame, new ProcessViewer());
        //   transaction.addToBackStack(null);
        select = 102;
        openprocesses = false;
        //title.setText(utils.getString(con, R.string.process_viewer));
        //Commit the transaction
        transaction.commitAllowingStateLoss();
        supportInvalidateOptionsMenu();
    } else if (intent.getAction() != null)
        if (intent.getAction().equals(Intent.ACTION_GET_CONTENT)) {

            // file picker intent
            mReturnIntent = true;
            Toast.makeText(this, utils.getString(con, R.string.pick_a_file), Toast.LENGTH_LONG).show();
        } else if (intent.getAction().equals(RingtoneManager.ACTION_RINGTONE_PICKER)) {
            // ringtone picker intent
            mReturnIntent = true;
            mRingtonePickerIntent = true;
            Toast.makeText(this, utils.getString(con, R.string.pick_a_file), Toast.LENGTH_LONG).show();
        } else if (intent.getAction().equals(Intent.ACTION_VIEW)) {
            // zip viewer intent
            Uri uri = intent.getData();
            zippath = uri.toString();
            openZip(zippath);
        }
}