Example usage for android.content Intent putStringArrayListExtra

List of usage examples for android.content Intent putStringArrayListExtra

Introduction

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

Prototype

public @NonNull Intent putStringArrayListExtra(String name, ArrayList<String> value) 

Source Link

Document

Add extended data to the intent.

Usage

From source file:com.prgpascal.qrdatatransfer.TransferActivity.java

/**
 * Method called when the transmission ended:
 * - The Client read the QR with EOT and sent the ack.
 * - The Server received the ACK for EOT.
 *
 * This method will not stop the ServerReceiver neither will disconnect Wifi Direct,
 * because that will be done in onStop() method.
 *//*w  w  w. jav  a  2  s .c  o m*/
public void finishTransmissionWithSuccess() {
    // Return to the calling Activity
    Intent returnIntent = new Intent();
    returnIntent.putExtra(I_AM_THE_SERVER, iAmTheServer);
    if (!iAmTheServer) {
        returnIntent.putStringArrayListExtra(MESSAGES, messages);
    }

    setResult(Activity.RESULT_OK, returnIntent);
    finish();
}

From source file:com.dazone.crewchat.libGallery.activity.HomeFragmentActivity.java

@Override
public void onClick(View v) {
    switch (v.getId()) {
    case R.id.cameraImageViewFromMediaChooserHeaderBar:
        if (v.getTag().toString().equals(getResources().getString(R.string.video))) {
            Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
            fileUri = getOutputMediaFileUri(MediaChooserConstants.MEDIA_TYPE_VIDEO); // create a file to save the image
            intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // set the image file name

            // start the image capture Intent
            startActivityForResult(intent, MediaChooserConstants.CAPTURE_VIDEO_ACTIVITY_REQUEST_CODE);

        } else {//from www  .  j  a  va  2 s.  c  o  m
            Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
            fileUri = getOutputMediaFileUri(MediaChooserConstants.MEDIA_TYPE_IMAGE); // create a file to save the image
            intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // set the image file name

            // start the image capture Intent
            startActivityForResult(intent, MediaChooserConstants.CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);
        }
        break;
    case R.id.doneTextViewViewFromMediaChooserHeaderView:
        FragmentManager fragmentManager = getSupportFragmentManager();
        ImageFragment imageFragment = (ImageFragment) fragmentManager.findFragmentByTag("tab1");
        VideoFragment videoFragment = (VideoFragment) fragmentManager.findFragmentByTag("tab2");

        if (videoFragment != null || imageFragment != null) {

            if (videoFragment != null) {
                if (videoFragment.getSelectedVideoList() != null
                        && videoFragment.getSelectedVideoList().size() > 0) {
                    Intent videoIntent = new Intent();
                    videoIntent.setAction(MediaChooser.VIDEO_SELECTED_ACTION_FROM_MEDIA_CHOOSER);
                    videoIntent.putStringArrayListExtra("list", videoFragment.getSelectedVideoList());
                    sendBroadcast(videoIntent);
                } else {
                    Toast.makeText(HomeFragmentActivity.this, getString(R.string.please_select_file),
                            Toast.LENGTH_SHORT).show();
                    return;
                }
            }

            if (imageFragment != null) {
                if (imageFragment.getSelectedImageList() != null
                        && imageFragment.getSelectedImageList().size() > 0) {
                    Intent imageIntent = new Intent();
                    imageIntent.setAction(MediaChooser.IMAGE_SELECTED_ACTION_FROM_MEDIA_CHOOSER);
                    imageIntent.putStringArrayListExtra("list", imageFragment.getSelectedImageList());
                    sendBroadcast(imageIntent);
                } else {
                    Toast.makeText(HomeFragmentActivity.this, getString(R.string.please_select_file),
                            Toast.LENGTH_SHORT).show();
                    return;
                }
            }
            if (BucketHomeFragmentActivity.Instance != null) {
                BucketHomeFragmentActivity.Instance.finish();
            }
            finish();
        } else {
            Toast.makeText(HomeFragmentActivity.this, getString(R.string.please_select_file),
                    Toast.LENGTH_SHORT).show();
        }
        break;
    case R.id.backArrowImageViewFromMediaChooserHeaderView:
        finish();
        break;
    default:
        break;
    }
}

From source file:eu.codeplumbers.cosi.activities.CozyActivity.java

@Override
public void onListFragmentInteraction(File file) {
    if (currentFragment instanceof FileManagerFragment) {
        if (!file.isFile()) {
            String path = file.getPath().equals("") ? "/" : file.getPath() + "/";
            ((FileManagerFragment) currentFragment).setCurrentPath(path + file.getName());
            ((FileManagerFragment) currentFragment).refreshList();
        } else {/*from w  w w . ja  v  a2s .c  o m*/
            if (file.getDownloaded()) {
                MimeTypeMap myMime = MimeTypeMap.getSingleton();
                Intent newIntent = new Intent(Intent.ACTION_VIEW);
                String mimeType = myMime
                        .getMimeTypeFromExtension(FileUtils.fileExt(file.getName()).substring(1));
                newIntent.setDataAndType(Uri.fromFile(file.getLocalPath()), mimeType);
                newIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                try {
                    startActivity(newIntent);
                } catch (ActivityNotFoundException e) {
                    Toast.makeText(this, "No handler for this type of file.", Toast.LENGTH_LONG).show();
                }
            } else {
                Intent intent = new Intent(CozyActivity.this, CosiFileDownloadService.class);
                ArrayList<String> arrayList = new ArrayList<String>();
                arrayList.add(0, file.getId() + "");
                intent.putStringArrayListExtra("fileToDownload", arrayList);
                startService(intent);
            }
        }
    }
}

From source file:foam.jellyfish.StarwispBuilder.java

public static void email(Context context, String emailTo, String emailCC, String subject, String emailText,
        List<String> filePaths) {
    //need to "send multiple" to get more than one attachment
    final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND_MULTIPLE);
    emailIntent.setType("text/plain");
    emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { emailTo });
    emailIntent.putExtra(android.content.Intent.EXTRA_CC, new String[] { emailCC });
    emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject);

    ArrayList<String> extra_text = new ArrayList<String>();
    extra_text.add(emailText);/*www . jav a  2  s.c o m*/
    emailIntent.putStringArrayListExtra(Intent.EXTRA_TEXT, extra_text);
    //emailIntent.putExtra(Intent.EXTRA_TEXT, emailText);

    //has to be an ArrayList
    ArrayList<Uri> uris = new ArrayList<Uri>();
    //convert from paths to Android friendly Parcelable Uri's
    for (String file : filePaths) {
        File fileIn = new File(file);
        Uri u = Uri.fromFile(fileIn);
        uris.add(u);
    }
    emailIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
    context.startActivity(Intent.createChooser(emailIntent, "Send mail..."));
}

From source file:com.zhaojian.jolly.fragment.UserPhotosFragment.java

private void excuteFinish() {
    if (mPhotoSelectionController.getSelectedCount() > 0) {
        Intent intent = new Intent();
        ArrayList<String> uri = new ArrayList<String>();
        for (PhotoUpload photoUpload : mPhotoSelectionController.getSelected()) {
            String filePath = Utils.getPathFromContentUri(getActivity().getContentResolver(),
                    photoUpload.getOriginalPhotoUri());
            uri.add(filePath);// w w w  .jav  a  2s  . com
        }
        intent.putStringArrayListExtra(PHOTO_URIS, uri);
        getActivity().setResult(Activity.RESULT_OK, intent);
        mPhotoSelectionController.clearSelected();
        getActivity().finish();
    }

}

From source file:net.wespot.pim.view.InqCommunicateFragment.java

private void createNotification(MessageLocalObject messageLocalObject, Long runId) {

    if (!runIdList.contains(runId)) {
        runIdList.add(runId);//from   w  ww. java  2 s  .c o m
        runIdList_str.add(runId.toString());
    }

    numMessages = 0;
    mBuilder = null;
    mNotificationStyle = null;
    mNotificationManager = null;

    mNotificationManager = (NotificationManager) ARL.getContext()
            .getSystemService(Context.NOTIFICATION_SERVICE);
    mNotificationStyle = new NotificationCompat.InboxStyle();
    mBuilder = new NotificationCompat.Builder(ARL.getContext()).setSmallIcon(R.drawable.ic_launcher)
            .setAutoCancel(true).setSortKey("0")
            .setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE)
            .setStyle(mNotificationStyle);

    InquiryLocalObject inquiryLocalObject = DaoConfiguration.getInstance().getInquiryLocalObjectDao()
            .queryBuilder().where(InquiryLocalObjectDao.Properties.RunId.eq(runId)).list().get(0);

    // The stack builder object will contain an artificial back stack for the
    // started Activity.
    // This ensures that navigating backward from the Activity leads out of
    // your application to the Home screen.
    TaskStackBuilder stackBuilder = TaskStackBuilder.create(ARL.getContext());

    Intent resultIntent;

    if (runIdList.size() > 1) {
        resultIntent = new Intent(ARL.getContext(), PimInquiriesFragment.class);
        resultIntent.putStringArrayListExtra(INQUIRIES_ID, (ArrayList<String>) runIdList_str);

        Intent parent = new Intent(ARL.getContext(), MainActivity.class);
        Intent parent1 = new Intent(ARL.getContext(), SplashActivity.class);

        // Adds the back stack for the Intent (but not the Intent itself)
        stackBuilder.addNextIntentWithParentStack(parent1);
        stackBuilder.addNextIntentWithParentStack(parent);

    } else {
        resultIntent = new Intent(ARL.getContext(), InquiryPhasesActivity.class);
        resultIntent.putExtra(INQUIRY_ID, inquiryLocalObject.getId());

        Intent parent = new Intent(ARL.getContext(), PimInquiriesFragment.class);
        Intent parent1 = new Intent(ARL.getContext(), MainActivity.class);
        Intent parent2 = new Intent(ARL.getContext(), SplashActivity.class);

        // Adds the back stack for the Intent (but not the Intent itself)
        stackBuilder.addNextIntentWithParentStack(parent2);
        stackBuilder.addNextIntentWithParentStack(parent1);
        stackBuilder.addNextIntentWithParentStack(parent);
    }

    // Adds the Intent that starts the Activity to the top of the stack
    stackBuilder.addNextIntent(resultIntent);
    PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);

    mBuilder.setContentIntent(resultPendingIntent);

    if (runIdList.size() == 1) {
        // More than 1 inquiries have messages

        mBuilder.setContentTitle(inquiryLocalObject.getTitle());
        for (MessageLocalObject me : notications_queue_messages) {
            mNotificationStyle.addLine(getNameUser(me.getAuthor()) + ": " + me.getBody()).setSummaryText(
                    ++numMessages != 1 ? numMessages + " new messages" : numMessages + " new message");
        }
    }

    if (runIdList.size() > 1) {
        // More than 1 inquiries have messages

        for (MessageLocalObject me : notications_queue_messages) {
            mBuilder.setContentTitle("Personal Inquiry Manager");
            InquiryLocalObject a = DaoConfiguration.getInstance().getInquiryLocalObjectDao().queryBuilder()
                    .where(InquiryLocalObjectDao.Properties.RunId.eq(me.getRunId())).list().get(0);

            mNotificationStyle.addLine(getNameUser(me.getAuthor()) + " @ " + a.getTitle() + ": " + me.getBody())
                    .setSummaryText(++numMessages != 1
                            ? numMessages + " new messages from " + runIdList.size() + " conversations" + " "
                            : numMessages + " new message from " + runIdList.size() + " conversations");
        }
    }

    mNotificationManager.notify(Integer.parseInt(NUMBER), mBuilder.build());
}

From source file:com.home.young.filepicker.AbstractFilePickerActivity.java

@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@Override/*w ww  . j  av  a 2  s.c o m*/
public void onFilesPicked(@NonNull final List<Uri> files) {
    Intent i = new Intent();
    i.putExtra(EXTRA_ALLOW_MULTIPLE, true);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        ClipData clip = null;
        for (Uri file : files) {
            if (clip == null) {
                clip = new ClipData("Paths", new String[] {}, new ClipData.Item(file));
            } else {
                clip.addItem(new ClipData.Item(file));
            }
        }
        i.setClipData(clip);
    } else {
        ArrayList<String> paths = new ArrayList<>();
        for (Uri file : files) {
            paths.add(file.toString());
        }
        i.putStringArrayListExtra(EXTRA_PATHS, paths);
    }

    setResult(Activity.RESULT_OK, i);
    finish();
}

From source file:cn.tycoon.lighttrans.fileManager.AbstractFilePickerActivity.java

@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@Override/*from  ww  w. java  2 s  .  c om*/
public void onFilesPicked(final List<Uri> files) {
    Intent i = new Intent();
    i.putExtra(EXTRA_ALLOW_MULTIPLE, true);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        ClipData clip = null;
        for (Uri file : files) {
            if (clip == null) {
                clip = new ClipData("Paths", new String[] {}, new ClipData.Item(file));
            } else {
                clip.addItem(new ClipData.Item(file));
            }
        }
        i.setClipData(clip);
    } else {
        ArrayList<String> paths = new ArrayList<>();
        for (Uri file : files) {
            paths.add(file.toString());
        }
        i.putStringArrayListExtra(EXTRA_PATHS, paths);
    }

    setResult(Activity.RESULT_OK, i);
    finish();
}

From source file:org.wso2.emm.agent.services.operation.OperationManagerOlderSdk.java

@Override
public void restrictAccessToApplications(Operation operation) throws AndroidAgentException {

    AppRestriction appRestriction = CommonUtils.getAppRestrictionTypeAndList(operation, getResultBuilder(),
            getContextResources());//from w ww  .j  a va2  s .c  o m

    String ownershipType = Preference.getString(getContext(), Constants.DEVICE_TYPE);

    if (Constants.AppRestriction.WHITE_LIST.equals(appRestriction.getRestrictionType())) {
        if (Constants.OWNERSHIP_COPE.equals(ownershipType)) {

            List<String> installedAppPackages = CommonUtils.getInstalledAppPackages(getContext());

            List<String> toBeHideApps = new ArrayList<>(installedAppPackages);
            toBeHideApps.removeAll(appRestriction.getRestrictedList());
            for (String packageName : toBeHideApps) {
                CommonUtils.callSystemApp(getContext(), operation.getCode(), "false", packageName);
            }
        }
    } else if (Constants.AppRestriction.BLACK_LIST.equals(appRestriction.getRestrictionType())) {
        if (Constants.OWNERSHIP_BYOD.equals(ownershipType)) {
            Intent restrictionIntent = new Intent(getContext(), AppLockService.class);
            restrictionIntent.setAction(Constants.APP_LOCK_SERVICE);

            restrictionIntent.putStringArrayListExtra(Constants.AppRestriction.APP_LIST,
                    (ArrayList) appRestriction.getRestrictedList());

            PendingIntent pendingIntent = PendingIntent.getService(getContext(), 0, restrictionIntent,
                    PendingIntent.FLAG_UPDATE_CURRENT);

            AlarmManager alarmManager = (AlarmManager) getContext().getSystemService(Context.ALARM_SERVICE);
            Calendar calendar = Calendar.getInstance();
            calendar.setTimeInMillis(System.currentTimeMillis());
            calendar.add(Calendar.SECOND, 1); // First time
            long frequency = 1 * 1000; // In ms
            alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), frequency,
                    pendingIntent);

            getContext().startService(restrictionIntent);
        } else if (Constants.OWNERSHIP_COPE.equals(ownershipType)) {

            for (String packageName : appRestriction.getRestrictedList()) {
                CommonUtils.callSystemApp(getContext(), operation.getCode(), "false", packageName);
            }
        }

    }
    operation.setStatus(getContextResources().getString(R.string.operation_value_completed));
    getResultBuilder().build(operation);

}

From source file:org.wso2.iot.agent.services.operation.OperationManagerWorkProfile.java

@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Override//from  w  w  w . j  av  a  2s  .co m
public void restrictAccessToApplications(Operation operation) throws AndroidAgentException {
    AppRestriction appRestriction = CommonUtils.getAppRestrictionTypeAndList(operation, getResultBuilder(),
            getContextResources());
    if (Constants.AppRestriction.BLACK_LIST.equals(appRestriction.getRestrictionType())) {
        Intent restrictionIntent = new Intent(getContext(), AppLockService.class);
        restrictionIntent.setAction(Constants.APP_LOCK_SERVICE);

        restrictionIntent.putStringArrayListExtra(Constants.AppRestriction.APP_LIST,
                (ArrayList) appRestriction.getRestrictedList());

        PendingIntent pendingIntent = PendingIntent.getService(getContext(), 0, restrictionIntent,
                PendingIntent.FLAG_UPDATE_CURRENT);

        AlarmManager alarmManager = (AlarmManager) getContext().getSystemService(Context.ALARM_SERVICE);
        Calendar calendar = Calendar.getInstance();
        calendar.setTimeInMillis(System.currentTimeMillis());
        calendar.add(Calendar.SECOND, 1); // First time
        long frequency = 1 * 1000; // In ms
        alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), frequency,
                pendingIntent);

        getContext().startService(restrictionIntent);

    } else if (Constants.AppRestriction.WHITE_LIST.equals(appRestriction.getRestrictionType())) {
        ArrayList appList = (ArrayList) appRestriction.getRestrictedList();
        JSONArray whiteListApps = new JSONArray();
        for (Object appObj : appList) {
            JSONObject app = new JSONObject();
            try {
                app.put(Constants.AppRestriction.PACKAGE_NAME, appObj.toString());
                app.put(Constants.AppRestriction.RESTRICTION_TYPE, Constants.AppRestriction.WHITE_LIST);
                whiteListApps.put(app);
            } catch (JSONException e) {
                operation.setStatus(getContextResources().getString(R.string.operation_value_error));
                operation.setOperationResponse("Error in parsing app white-list payload.");
                getResultBuilder().build(operation);
                throw new AndroidAgentException("Invalid JSON format for app white-list bundle.", e);
            }
        }
        Preference.putString(getContext(), Constants.AppRestriction.WHITE_LIST_APPS, whiteListApps.toString());
        validateInstalledApps();
    }
    operation.setStatus(getContextResources().getString(R.string.operation_value_completed));
    getResultBuilder().build(operation);
}