Example usage for android.content Intent setType

List of usage examples for android.content Intent setType

Introduction

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

Prototype

public @NonNull Intent setType(@Nullable String type) 

Source Link

Document

Set an explicit MIME data type.

Usage

From source file:com.streaming.sweetplayer.PlayerActivity.java

private Intent getDefaultIntent() {
    String urlToShare = Config.DOMAIN + sSongUrl;
    String sharingText = mActivity.getString(R.string.sharing_text) + " " + urlToShare + " "
            + mActivity.getString(R.string.sharing_android_app) + " " + Config.GOOGLE_PLAY_LINK;

    Intent sharingIntent = new Intent(Intent.ACTION_SEND);
    sharingIntent.setType("text/plain");
    sharingIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
    sharingIntent.putExtra(Intent.EXTRA_SUBJECT, sSongName);
    sharingIntent.putExtra(Intent.EXTRA_TEXT, sharingText);
    return sharingIntent;
}

From source file:it.gulch.linuxday.android.fragments.EventDetailsFragment.java

@SuppressLint("InlinedApi")
private void addToAgenda() {
    Intent intent = new Intent(Intent.ACTION_EDIT);
    intent.setType("vnd.android.cursor.item/event");
    intent.putExtra(CalendarContract.Events.TITLE, event.getTitle());
    intent.putExtra(CalendarContract.Events.EVENT_LOCATION, event.getTrack().getRoom().getName());
    String description = event.getEventAbstract();
    if (StringUtils.isBlank(description)) {
        description = event.getDescription();
    }/*  w w  w  .  ja v a  2  s  . com*/
    if (StringUtils.isBlank(description)) {
        description = StringUtils.EMPTY;
    }

    // FIXME
    // Strip HTML
    //description = StringUtils.stripEnd(Html.fromHtml(description).toString(), " ");
    // Add speaker info if available
    if (personsCount > 0) {
        String personsSummary = StringUtils.join(event.getPeople(), ", ");
        description = String.format("%1$s: %2$s\n\n%3$s",
                getResources().getQuantityString(R.plurals.speakers, personsCount), personsSummary,
                description);
    }
    intent.putExtra(CalendarContract.Events.DESCRIPTION, description);
    Date time = event.getStartDate();
    if (time != null) {
        intent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, time.getTime());
    }
    time = event.getEndDate();
    if (time != null) {
        intent.putExtra(CalendarContract.EXTRA_EVENT_END_TIME, time.getTime());
    }
    startActivity(intent);
}

From source file:com.google.cloud.solutions.smashpix.MainActivity.java

  /**
 * Gets a picture from the built in image gallery.
 *///from  w ww . j  a va2s. c o  m
public void getPicture()  {
  Intent intent = new Intent(Intent.ACTION_PICK,
      android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
  intent.setType(INTENT_IMAGE_PICK_FILTER);
  startActivityForResult(Intent.createChooser(intent,
      getResources().getString(R.string.select_image)), Constants.SELECT_PICTURE);
}

From source file:com.z.stproperty.PropertyDetail.java

/**
 * User can share this property details with their friends through email as well
 * and can choose other options like whats-app, drop-box etc as well
 *//*  w ww  . ja  v a  2  s . c  o  m*/
private void shareWithEmail() {
    try {
        String path = Images.Media.insertImage(getContentResolver(), SharedFunction.loadBitmap(shareImageLink),
                "title", null);
        Uri screenshotUri = Uri.parse(path);
        String shareContent = title + "\n\n" + prurl + "\n\n" + price + "\n\n";
        Intent intent = new Intent(Intent.ACTION_SEND);
        intent.setType("image/png");
        intent.putExtra(Intent.EXTRA_EMAIL, new String[] { "" });
        intent.putExtra(Intent.EXTRA_SUBJECT, "Property to share with you");
        intent.putExtra(Intent.EXTRA_TEXT,
                "I think you might be interested in a property advertised on STProperty \n\n" + shareContent);
        intent.putExtra(Intent.EXTRA_STREAM, screenshotUri);
        SharedFunction.postAnalytics(PropertyDetail.this, "Lead", "Email Share", title);
        startActivity(Intent.createChooser(intent, ""));
    } catch (Exception e) {
        Log.e(this.getClass().getSimpleName(), e.getLocalizedMessage(), e);
    }
}

From source file:de.stadtrallye.rallyesoft.model.pictures.PictureManager.java

/**
 * Get an intent to either take a picture with the camera app or select an app that can pick an existing picture
 *///w  ww  .ja  v a 2 s.c  o m
public Intent startPictureTakeOrSelect(SourceHint sourceHint) {
    //Attention: Our RequestCode will not be used for the result, if a jpeg is picked, data.getType will contain image/jpeg, if the picture was just taken with the camera it will be null
    Intent pickIntent = new Intent();
    pickIntent.setType("image/jpeg");
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        pickIntent.setAction(Intent.ACTION_OPEN_DOCUMENT);
        pickIntent.addCategory(Intent.CATEGORY_OPENABLE);
    } else {
        pickIntent.setAction(Intent.ACTION_GET_CONTENT);
    }

    Intent takePhotoIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);

    Uri fileUri = getPicturePlaceholderUri(PictureManager.MEDIA_TYPE_IMAGE, sourceHint); // reserve a filename to save the image
    takePhotoIntent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // set the image file name
    takePhotoIntent.putExtra("return-data", true);

    Intent chooserIntent = Intent.createChooser(pickIntent, context.getString(R.string.select_take_picture));
    chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[] { takePhotoIntent });

    return chooserIntent;
}

From source file:cw.kop.autobackground.settings.AppSettingsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    PreferenceCategory preferenceCategory = (PreferenceCategory) findPreference("title_app_settings");

    Preference clearPref = findPreference("clear_pref");
    clearPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override/*from  w  w w.  j  a  v  a 2 s . c o m*/
        public boolean onPreferenceClick(Preference preference) {
            if (appContext != null) {

                DialogFactory.ActionDialogListener listener = new DialogFactory.ActionDialogListener() {

                    @Override
                    public void onClickMiddle(View v) {
                        //                            AppSettings.debugVer2_00();
                        AppSettings.setUseTutorial(true);
                        this.dismissDialog();
                    }

                    @Override
                    public void onClickRight(View v) {
                        AppSettings.clearPrefs(appContext);
                        if (AppSettings.useToast()) {
                            Toast.makeText(appContext, "Resetting settings to default", Toast.LENGTH_SHORT)
                                    .show();
                        }
                        this.dismissDialog();
                        restartActivity();
                    }
                };

                DialogFactory.showActionDialog(appContext, "Reset All Settings?", "This cannot be undone.",
                        listener, -1, R.string.cancel_button, R.string.ok_button);

            }
            return true;
        }
    });

    findPreference("export_sources").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {

            if (appContext != null) {
                DialogFactory.ActionDialogListener listener = new DialogFactory.ActionDialogListener() {

                    @Override
                    public void onClickMiddle(View v) {
                        AppSettings.setUseTutorial(true);
                        this.dismissDialog();
                    }

                    @Override
                    public void onClickRight(View v) {

                        final File outputFile = new File(AppSettings.getDownloadPath() + "/Exported/SourceData"
                                + System.currentTimeMillis() + ".txt");
                        new Thread(new Runnable() {
                            @Override
                            public void run() {
                                exportSources(outputFile);
                            }
                        }).start();

                        if (AppSettings.useToast()) {
                            Toast.makeText(appContext, "Exporting to " + outputFile.getAbsolutePath(),
                                    Toast.LENGTH_SHORT).show();
                        }
                        this.dismissDialog();
                    }
                };

                DialogFactory.showActionDialog(appContext, "Export sources?", "", listener, -1,
                        R.string.cancel_button, R.string.ok_button);

            }
            return true;
        }
    });

    findPreference("import_sources").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {

            Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
            intent.setType("file/*");
            startActivityForResult(intent, IMPORT_SOURCES_REQUEST_CODE);

            return true;
        }
    });

    themePref = findPreference("change_theme");
    themePref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            showThemeDialogMenu();
            return true;
        }
    });

    setThemePrefSummary();

    Preference tutorialPref = findPreference("show_tutorial_source");
    tutorialPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            Toast.makeText(appContext, "Showing tutorial...", Toast.LENGTH_SHORT).show();
            Intent tutorialIntent = new Intent(appContext, TutorialActivity.class);
            startActivityForResult(tutorialIntent, TutorialActivity.TUTORIAL_REQUEST);
            return true;
        }
    });

    toastPref = (SwitchPreference) findPreference("use_toast");

    if (!AppSettings.useAdvanced()) {
        preferenceCategory.removePreference(toastPref);
        preferenceCategory.removePreference(findPreference("force_multi_pane"));
    }

    return inflater.inflate(R.layout.fragment_list, container, false);

}

From source file:palamarchuk.smartlife.app.fragments.ProfileFragment.java

private void feedback() {
    Intent sendIntent;
    sendIntent = new Intent(Intent.ACTION_SEND);
    sendIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { "support@smartlife.com.kz" });
    sendIntent.putExtra(Intent.EXTRA_SUBJECT, "");
    sendIntent.putExtra(Intent.EXTRA_TEXT, "");
    sendIntent.setType("image/jpeg");

    try {/* w w w .  j a  va2s . c om*/
        startActivity(Intent.createChooser(sendIntent, "Send Mail"));
    } catch (android.content.ActivityNotFoundException ex) {
        Toast.makeText(parentActivity, "There are no email clients installed.", Toast.LENGTH_SHORT).show();
    }
}

From source file:name.zurell.kirk.apps.android.rhetolog.RhetologApplication.java

/** Called when a session detail view asks to send session results somewhere. 
 * Generates a link to the session report Uri, and lets the remote program read from it. 
 * The {@link RhetologContentProvider} generates the result file on demand.
 * /* w ww  .j  a  v  a 2s  .  co m*/
 * */

@Override
public void onSessionSend(Context context, Uri session) {

    // Send to the program selected by the chooser below.
    Intent sendSession = new Intent(Intent.ACTION_SEND);

    // Permit to read from Rhetolog URIs.
    sendSession.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

    // Note type of send as report.
    sendSession.setType(RhetologContract.RHETOLOG_TYPE_SESSION_REPORT);

    sendSession.putExtra(Intent.EXTRA_SUBJECT, "Sending session " + session);

    // Send text as text.
    sendSession.putExtra(Intent.EXTRA_TEXT, reportForSession(session));

    // Send text as URI to be read.
    sendSession.putExtra(Intent.EXTRA_STREAM,
            Uri.parse(RhetologContract.SESSIONSREPORT + "/" + session.getLastPathSegment()));

    // Permit user to choose target of send.
    context.startActivity(Intent.createChooser(sendSession, "Send session results"));
}

From source file:org.yaoha.YaohaActivity.java

public boolean editFavs(MenuItem item, final ImageButton btn, final TextView tv) {
    if (item.getTitle() == EDIT_FAV_STRING) {
        openFavMenu(btn, tv);/* w ww. ja  va 2  s  .c  o  m*/
    } else if (item.getTitle() == EDIT_FAV_PIC) {
        Intent intent = new Intent();
        intent.setType("image/*");
        intent.setAction(Intent.ACTION_GET_CONTENT);
        actualButton = btn; //workaround, there must be a better way
        startActivityForResult(Intent.createChooser(intent, "Select Picture"), SELECT_PICTURE);
    } else if (item.getTitle() == REMOVE_FAV) {
        tv.setText(getText(R.string.add_favorite));
        btn.setImageResource(R.drawable.plus_sign_small);
        String tmp = "";
        final Editor edit = prefs.edit();
        if (btn.getId() == button_favorite_1.getId()) {
            tmp = "saved_fav_1_text";
        } else if (btn.getId() == button_favorite_2.getId()) {
            tmp = "saved_fav_2_text";
        } else if (btn.getId() == button_favorite_3.getId()) {
            tmp = "saved_fav_3_text";
        } else if (btn.getId() == button_favorite_4.getId()) {
            tmp = "saved_fav_4_text";
        } else if (btn.getId() == button_favorite_5.getId()) {
            tmp = "saved_fav_5_text";
        } else if (btn.getId() == button_favorite_6.getId()) {
            tmp = "saved_fav_6_text";
        }
        edit.remove(tmp);
        edit.commit();
    } else {
        Toast.makeText(this, "Placeholder - You schould never see this.", Toast.LENGTH_SHORT).show();
        return false;
    }
    return super.onContextItemSelected(item);
}

From source file:com.z.stproperty.PropertyDetailFragment.java

/**
 * onClick   :: OnClickListener/*from  w  w w. j  a v a2 s.  c o  m*/
 * 
 * Is common on-click listener for all the buttons and images in home screen
 * This is grouped into single listener to make easier to alter the code and reduce the 
 * line of code.
 * 
 * This will check the View ID to match with the predefined View-ID to identify
 * which view is clicked 
 * 
 * Based on the view id this will perform different functionalities 
 */
private void performClickAction(View v) {
    try {
        switch (v.getId()) {
        case R.id.LoanCalculator:
            Intent calIntent = new Intent(getActivity(), LoanCalculator.class);
            calIntent.putExtra("price", price);
            startActivity(calIntent);
            break;
        case R.id.AgentMobile:
            String url = "tel:" + mobileNoStr;
            url = url.replace("+65-", "");
            Intent callIntent = new Intent(Intent.ACTION_CALL);
            callIntent.setData(Uri.parse(url));
            startActivity(callIntent);
            break;
        case R.id.SendEmailBtn:
            String text = "I'm interested in your property advertised on STProperty\n\n" + "PROPERTY TITLE:"
                    + title + "\n" + "PRICE:" + price
                    + "\n\nClick on the following link to view more details about the property\n\n" + prurl;

            Intent intent = new Intent(Intent.ACTION_SEND);
            intent.setType("plain/text");
            intent.putExtra(Intent.EXTRA_EMAIL, new String[] { agentEmail });
            intent.putExtra(Intent.EXTRA_SUBJECT, "Enquiry");
            intent.putExtra(Intent.EXTRA_TEXT, text);
            SharedFunction.postAnalytics(PropertyDetailFragment.this.getActivity(), "Lead",
                    "Successful Email Enquiry", title);
            startActivity(Intent.createChooser(intent, ""));
            break;
        /**case R.id.SendEnquiryBtn:
           Intent enqInt = new Intent(getActivity(), SaleEnquiry.class);
           enqInt.putExtra("propertyId", detailsJson.getString("id"));
           enqInt.putExtra("agentId", detailsJson.getJSONObject("seller_info").getString("agent_cea_reg_no"));
           startActivity(enqInt);
           break;*/
        default:
            break;
        }
    } catch (Exception e) {
        Log.e(this.getClass().getSimpleName(), e.getLocalizedMessage(), e);
    }
}