Example usage for android.content Intent getStringArrayListExtra

List of usage examples for android.content Intent getStringArrayListExtra

Introduction

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

Prototype

public ArrayList<String> getStringArrayListExtra(String name) 

Source Link

Document

Retrieve extended data from the intent.

Usage

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

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

    if (resultCode == RESULT_OK) {

        if (requestCode == REQUEST_PICK_CONTACTS) {

            ArrayList<String> invitees = new ArrayList<String>();

            String username = resultIntent.getStringExtra(ContactsPickerActivity.EXTRA_RESULT_USERNAME);

            if (username != null)
                invitees.add(username);//from  w  w w.  j av a 2s  .  c  o  m
            else
                invitees = resultIntent.getStringArrayListExtra(ContactsPickerActivity.EXTRA_RESULT_USERNAMES);

            mConvoView.inviteContacts(invitees);

        }
        if (requestCode == REQUEST_SEND_IMAGE) {
            Uri uri = resultIntent.getData();

            if (uri == null) {
                return;
            }

            /**
            if (uri.getHost().equals("com.google.android.apps.photos.contentprovider"))
            {
                    
            try {
                String uriActual = URLDecoder.decode(uri.getPath(), "UTF-8");
                uriActual = uriActual.substring(uriActual.indexOf("content://"));
                uri = Uri.parse(uriActual);
            }
            catch (Exception e)
            {
                Log.e(ImApp.LOG_TAG,"error parsing photos app URI",e);
            }
                    
            }*/

            boolean deleteFile = false;
            boolean resizeImage = true;
            boolean importContent = true;
            handleSendDelete(uri, "image/jpeg", deleteFile, resizeImage, importContent);
        } else if (requestCode == REQUEST_SEND_FILE || requestCode == REQUEST_SEND_AUDIO) {
            Uri uri = resultIntent.getData();

            if (uri == null) {
                return;
            }
            boolean deleteFile = false;
            boolean resizeImage = false;
            boolean importContent = false;

            handleSendDelete(uri, null, deleteFile, resizeImage, importContent);
        } else if (requestCode == REQUEST_TAKE_PICTURE) {
            if (mLastPhoto != null) {
                boolean deleteFile = true;
                boolean resizeImage = true;
                boolean importContent = true;

                handleSendDelete(mLastPhoto, "image/jpeg", deleteFile, resizeImage, importContent);
                mLastPhoto = null;
            }

        }

    }
}

From source file:com.android.email.activity.zx.MessageView.java

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);

    setContentView(R.layout.message_view);

    mSubjectView = (TextView) findViewById(R.id.subject);
    mFromView = (TextView) findViewById(R.id.from);
    mToView = (TextView) findViewById(R.id.to);
    mCcView = (TextView) findViewById(R.id.cc);
    mCcContainerView = findViewById(R.id.cc_container);
    mDateView = (TextView) findViewById(R.id.date);
    mTimeView = (TextView) findViewById(R.id.time);
    mMessageContentView = (WebView) findViewById(R.id.message_content);
    mAttachments = (LinearLayout) findViewById(R.id.attachments);
    mAttachmentIcon = (ImageView) findViewById(R.id.attachment);
    mShowPicturesSection = findViewById(R.id.show_pictures_section);
    mSenderPresenceView = (ImageView) findViewById(R.id.presence);

    mMessageContentView.setVerticalScrollBarEnabled(false);
    mAttachments.setVisibility(View.GONE);
    mAttachmentIcon.setVisibility(View.GONE);

    mFromView.setOnClickListener(this);
    mSenderPresenceView.setOnClickListener(this);
    findViewById(R.id.reply).setOnClickListener(this);
    findViewById(R.id.reply_all).setOnClickListener(this);
    findViewById(R.id.delete).setOnClickListener(this);
    findViewById(R.id.show_pictures).setOnClickListener(this);

    mMessageContentView.getSettings().setBlockNetworkImage(true);
    mMessageContentView.getSettings().setSupportZoom(false);

    setTitle("");

    mDateFormat = android.text.format.DateFormat.getDateFormat(this); // short format
    mTimeFormat = android.text.format.DateFormat.getTimeFormat(this); // 12/24 date format

    Intent intent = getIntent();
    mAccount = (Account) intent.getSerializableExtra(EXTRA_ACCOUNT);
    mFolder = intent.getStringExtra(EXTRA_FOLDER);
    mMessageUid = intent.getStringExtra(EXTRA_MESSAGE);
    mFolderUids = intent.getStringArrayListExtra(EXTRA_FOLDER_UIDS);

    View next = findViewById(R.id.next);
    View previous = findViewById(R.id.previous);
    /*/*from   ww  w .j a  va2  s .  com*/
     * Next and Previous Message are not shown in landscape mode, so
     * we need to check before we use them.
     */
    if (next != null && previous != null) {
        next.setOnClickListener(this);
        previous.setOnClickListener(this);

        findSurroundingMessagesUid();

        previous.setVisibility(mPreviousMessageUid != null ? View.VISIBLE : View.GONE);
        next.setVisibility(mNextMessageUid != null ? View.VISIBLE : View.GONE);

        boolean goNext = intent.getBooleanExtra(EXTRA_NEXT, false);
        if (goNext) {
            next.requestFocus();
        }
    }

    MessagingController.getInstance(getApplication()).addListener(mListener);
    new Thread() {
        @Override
        public void run() {
            // TODO this is a spot that should be eventually handled by a MessagingController
            // thread pool. We want it in a thread but it can't be blocked by the normal
            // synchronization stuff in MC.
            Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
            MessagingController.getInstance(getApplication()).loadMessageForView(mAccount, mFolder, mMessageUid,
                    mListener);
        }
    }.start();
}

From source file:indrora.atomic.activity.ConversationActivity.java

/**
 * On activity result//from   w  ww. ja va2  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) {
            ((EditText) findViewById(R.id.input)).setText(matches.get(0));
        }
        break;
    case REQUEST_CODE_JOIN:
        joinChannelBuffer = data.getExtras().getString("channel");
        break;
    case REQUEST_CODE_NICK_COMPLETION:
        insertNickCompletion((EditText) findViewById(R.id.input), data.getExtras().getString(Extra.USER));
        break;
    }
}

From source file:com.qiscus.sdk.ui.fragment.QiscusBaseChatFragment.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == FilePickerConst.REQUEST_CODE_PHOTO && resultCode == Activity.RESULT_OK) {
        if (data == null) {
            showError(getString(R.string.chat_error_failed_open_picture));
            return;
        }/*  www  .java2  s  .  c o m*/
        ArrayList<String> paths = data.getStringArrayListExtra(FilePickerConst.KEY_SELECTED_MEDIA);
        if (paths.size() > 0) {
            sendFile(new File(paths.get(0)));
        }
    } else if (requestCode == FilePickerConst.REQUEST_CODE_DOC && resultCode == Activity.RESULT_OK) {
        if (data == null) {
            showError(getString(R.string.chat_error_failed_open_file));
            return;
        }
        ArrayList<String> paths = data.getStringArrayListExtra(FilePickerConst.KEY_SELECTED_DOCS);
        if (paths.size() > 0) {
            sendFile(new File(paths.get(0)));
        }
    } else if (requestCode == TAKE_PICTURE_REQUEST && resultCode == Activity.RESULT_OK) {
        try {
            sendFile(QiscusFileUtil.from(Uri.parse(QiscusCacheManager.getInstance().getLastImagePath())));
        } catch (Exception e) {
            showError(getString(R.string.chat_error_failed_read_picture));
            e.printStackTrace();
        }
    }
}

From source file:com.orangelabs.rcs.ri.messaging.chat.group.GroupChatView.java

@Override
public boolean processIntent(Intent intent) {
    String action = intent.getAction();
    if (LogUtils.isActive) {
        Log.d(LOGTAG, "processIntent: " + action);
    }//from  w w  w  .j  ava2  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(GroupChatView.EXTRA_SUBJECT);
            updateGroupChatViewTitle(mSubject);
            /* Get the list of participants */
            ContactUtil contactUtil = ContactUtil.getInstance(this);
            List<String> contacts = intent.getStringArrayListExtra(GroupChatView.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;
            }
            setCursorLoader(oldChatId == null);
            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);
            sChatIdOnForeground = mChatId;
            ContactId contact = mGroupChat.getRemoteContact();
            mSubject = mGroupChat.getSubject();
            updateGroupChatViewTitle(mSubject);
            mParticipants = mGroupChat.getParticipants().keySet();
            /* Display accept/reject dialog */
            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.android.dialer.DialtactsActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == ACTIVITY_REQUEST_CODE_VOICE_SEARCH) {
        if (resultCode == 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   w  w  w  .  j a  v a  2  s.  c o m*/
        } else {
            Log.e(TAG, "Voice search failed");
        }
    }
    super.onActivityResult(requestCode, resultCode, data);
}

From source file:org.strongswan.android.ui.VpnProfileDetailActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
    case SELECT_TRUSTED_CERTIFICATE:
        if (resultCode == RESULT_OK) {
            String alias = data.getStringExtra(VpnProfileDataSource.KEY_CERTIFICATE);
            X509Certificate certificate = TrustedCertificateManager.getInstance()
                    .getCACertificateFromAlias(alias);
            mCertEntry = certificate == null ? null : new TrustedCertificateEntry(alias, certificate);
            updateCertificateSelector();
        }/* w  ww. ja v  a2s  .c o m*/
        break;
    case SELECT_APPLICATIONS:
        if (resultCode == RESULT_OK) {
            ArrayList<String> selection = data
                    .getStringArrayListExtra(VpnProfileDataSource.KEY_SELECTED_APPS_LIST);
            mSelectedApps = new TreeSet<>(selection);
            updateAppsSelector();
        }
        break;
    default:
        super.onActivityResult(requestCode, resultCode, data);
    }
}

From source file:org.alfresco.mobile.android.application.activity.MainActivity.java

@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    try {// www.  ja  va 2  s .c  om
        // Shortcut to display favorites panel.
        if (PrivateIntent.ACTION_SYNCHRO_DISPLAY.equals(intent.getAction())) {
            if (!isVisible(SyncFragment.TAG)) {
                SyncFragment.with(this).display();
            }
            return;
        }

        // Intent for Scan result
        // Only associated with DocumentFolderBrowserFragment
        if (PrivateIntent.ACTION_SCAN_RESULT.equals(intent.getAction())) {
            if (getFragment(DocumentFolderBrowserFragment.TAG) != null && intent.getExtras() != null) {
                ArrayList<String> tempList = intent.getStringArrayListExtra(PrivateIntent.EXTRA_FILE_PATH);
                if (tempList == null) {
                    return;
                }
                List<File> files = new ArrayList<File>(tempList.size());
                int nCnt;
                for (nCnt = tempList.size(); nCnt > 0; nCnt--) {
                    files.add(new File(tempList.get(nCnt - 1)));
                }
                ((DocumentFolderBrowserFragment) getFragment(DocumentFolderBrowserFragment.TAG))
                        .createFiles(files);
            }
            return;
        }

        // Is it from an alfresco shortcut ?
        openShortcut(intent);
    } catch (Exception e) {
        Log.w(TAG, Log.getStackTraceString(e));
    }
}

From source file:com.google.sample.cast.refplayer.Synchronization.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == REQUEST_CODE && resultCode == RESULT_OK) {
        ArrayList<String> matches = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
        if (matches.size() > 0) {
            Log.d(TAG, matches.get(0));//from  ww w  .j a v a 2  s  .c o  m
            //sendMessage(matches.get(0));
        }
    }
    super.onActivityResult(requestCode, resultCode, data);
}

From source file:io.hypertrack.sendeta.view.Home.java

/**
 * Method to handle Tracking url deeplinks to enable live location sharing amongst friends
 *///  w  w  w. ja  va 2 s . c  o m
private void handleTrackingUrlDeeplink() {
    Intent intent = getIntent();
    if (intent != null && intent.getBooleanExtra(Track.KEY_TRACK_DEEPLINK, false)) {
        // Add ProgressDialog
        mProgressDialog = new ProgressDialog(this);
        mProgressDialog.setCancelable(false);
        mProgressDialog.setMessage(getString(R.string.fetching_details_msg));
        mProgressDialog.show();

        // Get required parameters for tracking Actions on map
        lookupId = intent.getStringExtra(Track.KEY_LOOKUP_ID);
        List<String> actionIDs = intent.getStringArrayListExtra(Track.KEY_ACTION_ID_LIST);

        // Call trackActionsOnMap method
        presenter.trackActionsOnMap(lookupId, actionIDs, ActionManager.getSharedManager(this));
    }
}