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:com.sdspikes.fireworks.FireworksActivity.java

private void handleSelectPlayersResult(int response, Intent data) {
    if (response != Activity.RESULT_OK) {
        Log.w(TAG, "*** select players UI cancelled, " + response);
        switchToMainScreen();/*  w ww. j a v a 2  s  . c  o  m*/
        return;
    }

    Log.d(TAG, "Select players UI succeeded.");

    // get the invitee list
    final ArrayList<String> invitees = data.getStringArrayListExtra(Games.EXTRA_PLAYER_IDS);
    Log.d(TAG, "Invitee count: " + invitees.size());

    // get the 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 || maxAutoMatchPlayers > 0) {
        autoMatchCriteria = RoomConfig.createAutoMatchCriteria(minAutoMatchPlayers, maxAutoMatchPlayers, 0);
        Log.d(TAG, "Automatch criteria: " + autoMatchCriteria);
    }

    // create the room
    Log.d(TAG, "Creating room...");
    RoomConfig.Builder rtmConfigBuilder = RoomConfig.builder(this);
    rtmConfigBuilder.addPlayersToInvite(invitees);
    rtmConfigBuilder.setMessageReceivedListener(this);
    rtmConfigBuilder.setRoomStatusUpdateListener(this);
    if (autoMatchCriteria != null) {
        rtmConfigBuilder.setAutoMatchCriteria(autoMatchCriteria);
    }
    switchToScreen(R.id.screen_wait);
    keepScreenOn();
    resetGameVars();
    Games.RealTimeMultiplayer.create(mGoogleApiClient, rtmConfigBuilder.build());
    Log.d(TAG, "Room created, waiting for it to be ready...");
}

From source file:es.uma.lcc.lockpic.MainActivity.java

/**
 * reactions to results of activities/*from  w w  w  .  ja v  a 2s. c o m*/
 */

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == ACTIVITY_SELECTOR && resultCode == RESULT_OK) {
        encryptImage(data);
    } else if (requestCode == ACTIVITY_PICK_IMAGE_ENC && resultCode == RESULT_OK) {
        String path = LockPicIO.getPathFromIntent(MainActivity.this, data);
        if (path != null) {
            selectRegions(path);
        } else {
            Toast.makeText(this, R.string.unreachablePathWarning, Toast.LENGTH_SHORT).show();
        }
    } else if (requestCode == ACTIVITY_PICK_IMAGE_DEC && resultCode == RESULT_OK) {
        String path = LockPicIO.getPathFromIntent(MainActivity.this, data);
        if (path != null) {
            decryptImage(path);
        } else {
            Toast.makeText(this, R.string.unreachablePathWarning, Toast.LENGTH_SHORT).show();
        }
    } else if (requestCode == ACTIVITY_VIEW_MY_PICTURES && resultCode == RESULT_OK) {
        if (data.getStringExtra("picId") != null)
            queryPermissions(data.getStringExtra("picId"));
    } else if (requestCode == ACTIVITY_PICTURE_DETAILS && resultCode == RESULT_OK) {
        if (data.getStringArrayListExtra("operations") != null
                && data.getStringArrayListExtra("operations").size() > 0)
            sendUpdateToServer(data.getStringArrayListExtra("operations"), data.getStringExtra("picId"));
    }
}

From source file:org.proninyaroslav.libretorrent.TorrentTaskService.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    if (intent != null) {
        ArrayList<String> ids = intent.getStringArrayListExtra(TorrentTaskServiceIPC.TAG_TORRENT_IDS_LIST);

        if (ids != null) {
            List<Torrent> torrents = new ArrayList<>();

            for (String id : ids) {
                torrents.add(repo.getTorrentByID(id));
            }//from www .ja  va 2 s.  c  o m

            addTorrents(torrents);
        }
    }

    if (isAlreadyRunning) {
        if (intent != null && intent.getAction() != null) {
            switch (intent.getAction()) {
            case NotificationReceiver.NOTIFY_ACTION_SHUTDOWN_APP:
                ipc.sendTerminateAllClients(clientCallbacks);
                clientCallbacks.clear();
                stopForeground(true);
                stopSelf(startId);
                break;
            }
        }

        return START_STICKY;
    }

    /* The first start */
    isAlreadyRunning = true;

    makeForegroundNotify();
    startUpdateForegroundNotify();

    return START_STICKY;
}

From source file:com.gsma.rcs.ri.messaging.GroupTalkView.java

private boolean processIntent(Intent intent) {
    String action = intent.getAction();
    if (LogUtils.isActive) {
        Log.d(LOGTAG, "processIntent: " + action);
    }/*from ww w  .j  a va  2  s .c  o  m*/
    String oldChatId = mChatId;
    try {
        switch ((GroupChatMode) intent.getSerializableExtra(EXTRA_MODE)) {
        case OUTGOING:
            /* Initiate a Group Chat: Get subject */
            mSubject = intent.getStringExtra(GroupTalkView.EXTRA_SUBJECT);
            updateGroupChatViewTitle(mSubject);
            /* Get the list of participants */
            ContactUtil contactUtil = ContactUtil.getInstance(this);
            List<String> contacts = intent.getStringArrayListExtra(GroupTalkView.EXTRA_PARTICIPANTS);
            if (contacts == null || contacts.isEmpty()) {
                showMessageThenExit(R.string.label_invalid_contacts);
                return false;
            }
            for (String contact : contacts) {
                mParticipants.add(contactUtil.formatContact(contact));
            }
            if (mParticipants.isEmpty()) {
                showMessageThenExit(R.string.label_invalid_contacts);
                return false;
            }
            return initiateGroupChat(oldChatId == null);

        case OPEN:
            /* Open an existing session from the history log */
            mChatId = intent.getStringExtra(GroupChatIntent.EXTRA_CHAT_ID);
            mGroupChat = mChatService.getGroupChat(mChatId);
            if (mGroupChat == null) {
                if (LogUtils.isActive) {
                    Log.e(LOGTAG, "Groupchat not found for Id=".concat(mChatId));
                }
                showMessageThenExit(R.string.label_session_not_found);
                return false;
            }
            ChatPendingIntentManager.getChatPendingIntentManager(this).clearNotification(mChatId);
            setCursorLoader(oldChatId == null);
            RI.sChatIdOnForeground = mChatId;
            mSubject = mGroupChat.getSubject();
            updateGroupChatViewTitle(mSubject);
            /* Set list of participants */
            mParticipants = mGroupChat.getParticipants().keySet();
            if (LogUtils.isActive) {
                Log.i(LOGTAG, "processIntent chatId=" + mChatId + " subject='" + mSubject + "'");
            }
            return true;

        case INCOMING:
            String rxChatId = intent.getStringExtra(GroupChatIntent.EXTRA_CHAT_ID);
            if (GroupChatIntent.ACTION_NEW_GROUP_CHAT_MESSAGE.equals(action)) {
                String rxMsgId = intent.getStringExtra(GroupChatIntent.EXTRA_MESSAGE_ID);
                mChatService.markMessageAsRead(rxMsgId);
            }
            mChatId = rxChatId;
            mGroupChat = mChatService.getGroupChat(mChatId);
            if (mGroupChat == null) {
                showMessageThenExit(R.string.label_session_not_found);
                return false;
            }
            setCursorLoader(oldChatId == null);
            RI.sChatIdOnForeground = mChatId;
            ContactId contact = mGroupChat.getRemoteContact();
            mSubject = mGroupChat.getSubject();
            updateGroupChatViewTitle(mSubject);
            mParticipants = mGroupChat.getParticipants().keySet();
            /* Display accept/reject dialog */
            if (LogUtils.isActive) {
                Log.d(LOGTAG, "New group chat for chatId " + mChatId + " state=" + mGroupChat.getState());
            }
            if (GroupChat.State.INVITED == mGroupChat.getState()) {
                displayAcceptRejectDialog(contact);
            }
            if (LogUtils.isActive) {
                Log.d(LOGTAG, "New group chat for chatId ".concat(mChatId));
            }
            return true;
        }

    } catch (RcsServiceException e) {
        showExceptionThenExit(e);
    }
    return false;
}

From source file:com.arlib.floatingsearchview.FloatingSearchView.java

/**
 * Handles voice recognition activity return.
 *
 * <p>In order for voice rec to work, this must be called from
 * the client activity's onActivityResult()</p>
 *
 * @param requestCode  the code with which the voice recognition intent
 *                     was started.//w ww  .j av a 2  s .  c  o m
 * @param resultCode
 * @param data
 */
public void onHostActivityResult(int requestCode, int resultCode, Intent data) {

    if (requestCode == mVoiceRecRequestCode) {

        if (resultCode == Activity.RESULT_OK) {

            ArrayList<String> matches = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
            if (!matches.isEmpty()) {

                String newQuery = matches.get(0);

                mSearchInput.requestFocus();

                mSearchInput.setText(newQuery);
                mSearchInput.setSelection(mSearchInput.getText().length());
            }
        }
    }
}

From source file:com.dan.wizardduel.MainActivity.java

@Override
public void onActivityResult(int request, int response, Intent data) {
    super.onActivityResult(request, response, data);
    Log.e("tag", "activity result: " + request + " , " + response);
    if (request == RC_INVITATION_INBOX) {
        if (response != Activity.RESULT_OK) {
            mMainMenuFragment.stopLoading();
            return;
        }//from   w w  w.j a v  a 2  s  .  c om

        // get the selected invitation
        Bundle extras = data.getExtras();
        Invitation invitation = extras.getParcelable(GamesClient.EXTRA_INVITATION);

        // accept it!
        RoomConfig roomConfig = makeBasicRoomConfigBuilder()
                .setInvitationIdToAccept(invitation.getInvitationId()).build();
        getGamesClient().joinRoom(roomConfig);

        // prevent screen from sleeping during handshake
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

        // go to game screen
    } else if (request == RC_SELECT_PLAYERS) {
        if (response != Activity.RESULT_OK) {
            mMainMenuFragment.stopLoading();
            return;
        }

        // get the invitee list
        Bundle extras = data.getExtras();
        final ArrayList<String> invitees = data.getStringArrayListExtra(GamesClient.EXTRA_PLAYERS);

        // get automatch criteria
        Bundle autoMatchCriteria = null;
        int minAutoMatchPlayers = data.getIntExtra(GamesClient.EXTRA_MIN_AUTOMATCH_PLAYERS, 0);
        int maxAutoMatchPlayers = data.getIntExtra(GamesClient.EXTRA_MAX_AUTOMATCH_PLAYERS, 0);

        if (minAutoMatchPlayers > 0) {
            autoMatchCriteria = RoomConfig.createAutoMatchCriteria(1, 1, 0);//minAutoMatchPlayers, maxAutoMatchPlayers, 0);
        } else {
            autoMatchCriteria = null;
        }

        // create the room and specify a variant if appropriate
        RoomConfig.Builder roomConfigBuilder = makeBasicRoomConfigBuilder();
        roomConfigBuilder.addPlayersToInvite(invitees);
        if (autoMatchCriteria != null) {
            roomConfigBuilder.setAutoMatchCriteria(autoMatchCriteria);
        }
        RoomConfig roomConfig = roomConfigBuilder.build();
        getGamesClient().createRoom(roomConfig);

        // prevent screen from sleeping during handshake
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    } else if (request == RC_WAITING_ROOM) {
        if (response != Activity.RESULT_OK) {
            mMainMenuFragment.stopLoading();
            return;
        }
    } else if (request == RC_LEADERBOARD) {
        mMainMenuFragment.stopLoading();
    }
}

From source file:com.todotxt.todotxttouch.TodoTxtTouch.java

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

    Log.v(TAG, "onActivityResult: resultCode=" + resultCode + " i=" + data);

    if (requestCode == REQUEST_FILTER) {
        if (resultCode == Activity.RESULT_OK) {
            m_app.m_prios = Priority.toPriority(data.getStringArrayListExtra(Constants.EXTRA_PRIORITIES));
            m_app.m_projects = data.getStringArrayListExtra(Constants.EXTRA_PROJECTS);
            m_app.m_contexts = data.getStringArrayListExtra(Constants.EXTRA_CONTEXTS);
            m_app.m_search = data.getStringExtra(Constants.EXTRA_SEARCH);
            m_app.m_filters = data.getStringArrayListExtra(Constants.EXTRA_APPLIED_FILTERS);
            setDrawerChoices();/*  ww  w.  jav a 2 s  .  c om*/
            m_app.storeFilters();
            setFilteredTasks(false);
        }
    } else if (requestCode == REQUEST_PREFERENCES) {
        /* Do nothing */
    }
}

From source file:org.proninyaroslav.libretorrent.services.TorrentTaskService.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    if (intent != null) {
        ArrayList<String> ids = intent.getStringArrayListExtra(TorrentTaskServiceIPC.TAG_TORRENT_IDS_LIST);

        if (ids != null) {
            List<Torrent> torrents = new ArrayList<>();

            for (String id : ids) {
                torrents.add(repo.getTorrentByID(id));
            }/* w  w w  .  ja v  a  2 s  .c o  m*/

            addTorrents(torrents);
        }
    }

    if (isAlreadyRunning) {
        if (intent != null && intent.getAction() != null) {
            switch (intent.getAction()) {
            case NotificationReceiver.NOTIFY_ACTION_SHUTDOWN_APP:
                ipc.sendTerminateAllClients(clientCallbacks);
                clientCallbacks.clear();
                stopForeground(true);
                stopSelf(startId);
                break;
            case Intent.ACTION_BATTERY_LOW:
                if (pref.getBoolean(getString(R.string.pref_key_battery_control), false)) {
                    pauseTorrents.set(true);
                    pauseAll();
                }
                break;
            case Intent.ACTION_BATTERY_OKAY:
                if (pref.getBoolean(getString(R.string.pref_key_battery_control), false)
                        && !pref.getBoolean(getString(R.string.pref_key_download_and_upload_only_when_charging),
                                false)) {
                    pauseTorrents.set(false);
                    resumeAll();
                }
                break;
            case Intent.ACTION_POWER_CONNECTED:
                if (pref.getBoolean(getString(R.string.pref_key_download_and_upload_only_when_charging),
                        false)) {
                    pauseTorrents.set(false);
                    resumeAll();
                }
                break;
            case Intent.ACTION_POWER_DISCONNECTED:
                if (pref.getBoolean(getString(R.string.pref_key_download_and_upload_only_when_charging),
                        false)) {
                    pauseTorrents.set(true);
                    pauseAll();
                }
                break;
            }
        }

        return START_STICKY;
    }

    /* The first start */
    isAlreadyRunning = true;

    makeForegroundNotify();
    startUpdateForegroundNotify();

    return START_STICKY;
}

From source file:org.gots.ui.NewSeedActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if ((requestCode == REQUEST_LOAD_IMAGE || requestCode == REQUEST_TAKE_PHOTO) && resultCode == RESULT_OK
            && null != data) {/*from  w  w  w  . ja v a 2  s . c o m*/

        if (!validateSeed()) {
            Toast.makeText(getApplicationContext(), "Seed must be validable to execute this action",
                    Toast.LENGTH_LONG).show();
            return;
        }
        Uri selectedImage = data.getData();
        String[] filePathColumn = { MediaStore.Images.Media.DATA };

        Cursor cursor = getContentResolver().query(selectedImage, filePathColumn, null, null, null);
        cursor.moveToFirst();

        int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
        picturePath = cursor.getString(columnIndex);

        Bitmap bitmap = FileUtilities.decodeScaledBitmapFromSdCard(picturePath, 100, 100);

        ImageView image = (ImageView) findViewById(R.id.imageNewVariety);
        image.setImageBitmap(bitmap);

        cursor.close();

    } else if (requestCode == REQUEST_DISEASES || requestCode == REQUEST_ENVIRONMENT
            || requestCode == REQUEST_GROWTH || requestCode == REQUEST_HARVEST) {
        ArrayList<String> matches = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
        if (matches.size() > 0)
            switch (requestCode) {
            case REQUEST_GROWTH:
                descriptionGrowth.setText(matches.get(0));
                newSeed.setDescriptionGrowth(matches.toArray().toString());
                break;
            case REQUEST_DISEASES:
                descriptionDiseases.setText(matches.get(0));
                newSeed.setDescriptionDiseases(matches.toArray().toString());
                break;
            case REQUEST_ENVIRONMENT:
                descriptionEnvironment.setText(matches.get(0));
                newSeed.setDescriptionCultivation(matches.toArray().toString());
                break;
            case REQUEST_HARVEST:
                descriptionHarvest.setText(matches.get(0));
                newSeed.setDescriptionHarvest(matches.toArray().toString());
                break;
            default:
                break;
            }

    } else {
        IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
        if (scanResult != null && scanResult.getContents() != "") {
            Log.i("Scan result", scanResult.toString());
            textViewBarCode.setText(scanResult.getContents());
            newSeed.setBareCode(textViewBarCode.getText().toString());
        } else {

        }
    }
}

From source file:net.soulwolf.image.picturelib.PictureProcess.java

public void onProcessResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == PictureProcess.CAMERA_REQUEST_CODE) {
        if (resultCode == Activity.RESULT_OK && mCameraPath != null) {
            if (isClip) {
                cropPicture(mCameraPath);
            } else {
                onSuccess(mCameraPath);//  w  ww.ja v  a2  s .  c  o  m
            }
        } else {
            if (mOnPicturePickListener != null) {
                mOnPicturePickListener.onError(
                        new PhotographException("resultCode != Activity.RESULT_OK || mCameraPath == null"));
            }
        }
    } else if (requestCode == PictureProcess.CLIP_REQUEST_CODE) {
        if (resultCode == Activity.RESULT_OK && data != null) {
            Bitmap bitmap = data.getParcelableExtra("data");
            if (bitmap != null && Utils.saveBitmap(bitmap, mCropPath, mClipWidth, mClipHeight)) {
                onSuccess(mCropPath);
            } else {
                if (mOnPicturePickListener != null) {
                    mOnPicturePickListener
                            .onError(new PictureCropException("data.getParcelableExtra(\"data\") == NULL"));
                }
            }
        } else {
            if (mOnPicturePickListener != null) {
                mOnPicturePickListener
                        .onError(new PictureCropException("resultCode != Activity.RESULT_OK || data == null"));
            }
        }
    } else if (requestCode == PictureProcess.GALLERY_REQUEST_CODE) {
        if (resultCode == PictureChooseActivity.RESULT_OK && data != null) {
            ArrayList<String> picture = data.getStringArrayListExtra(Constants.PICTURE_CHOOSE_LIST);
            if (isClip && picture != null && picture.size() == 1) {
                cropPicture(new File(picture.get(0)));
            } else {
                onSuccess(picture);
            }
        }
    }
}