Intent createChooser - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Intent createChooser method.

This code example shows how to use the following methods:createChooser, putExtra, setType
    static Context context;
 
    /* Deliver some data to someone else 
    */ 
    static void send(String mimeType, String filename, String subject, String text, String chooser_title) {
        Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
        emailIntent.setType(mimeType);
        /** tryied with String [] emails, but hard to code the whole C/Cython part. 
          if (emails != null) 
          emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, emails); 
         **/ 
        if (subject != null)
            emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
        if (text != null)
            emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, text);
        if (filename != null)
            emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://"+ filename));
        if (chooser_title == null)
            chooser_title = "Send mail";
        context.startActivity(Intent.createChooser(emailIntent, chooser_title));

9
CodeRank
This code example shows how to use the following methods:createChooser, setType
        button.setOnClickListener(mGetMusicListener);
    } 
 
    private OnClickListener mGetMusicListener = new OnClickListener() {
        public void onClick(View v) { 
            Intent intent = new Intent(Intent.ACTION_GET_CONTENT); 
            intent.setType("audio/*"); 
            startActivity(Intent.createChooser(intent, "Select music")); 
        } 
    }; 
} 
7
CodeRank
This code example shows how to use the following methods:createChooser, putExtra, setType
        actionBar.addAction(new IntentAction(this, createShareIntent(), R.drawable.ic_title_share_default));
        actionBar.addAction(new ExampleAction());
    } 
 
    private Intent createShareIntent() {
        final Intent intent = new Intent(Intent.ACTION_SEND);
        intent.setType("text/plain");
        intent.putExtra(Intent.EXTRA_TEXT, "Shared from the ActionBar widget.");
        return Intent.createChooser(intent, "Share");
    } 
 
    private class ExampleAction extends AbstractAction { 
 
        public ExampleAction() { 
            super(R.drawable.ic_title_export_default); 
        } 
 
        @Override 
        public void performAction(View view) {
            Toast.makeText(OtherActivity.this,
9
CodeRank
This code example shows how to use the following methods:createChooser
	} 
 
	@Kroll.method 
	public IntentProxy createIntentChooser(IntentProxy target, String title)
	{ 
		return new IntentProxy(Intent.createChooser(target.getIntent(), title));
	} 
 
	@Kroll.getProperty(name="R") 
	public RProxy getR() { 
		if (r == null) {
			r = new RProxy(RProxy.RESOURCE_TYPE_ANDROID);
		} 
		return r;
	} 
 
	@Kroll.method 
	public void startService(IntentProxy intentProxy)
	{ 
		TiApplication app = TiApplication.getInstance();
6
CodeRank
This code example shows how to use the following methods:createChooser, putExtra, setType
This code example shows how to use the following methods:createChooser, putExtra, setType
		openEmail(ctx, pBody, "AndRoad-Exception (v" + org.androad.util.Util.getVersionName(ctx) + ")", new String[]{"support@andnav.org"});
		Toast.makeText(ctx, "Please describe your bug!", Toast.LENGTH_LONG).show();
	} 
 
	public static void openEmail(final Context ctx, final String pBody, final String pSubject, final String[] pReceivers) {
		final Intent mailIntent = new Intent(android.content.Intent.ACTION_SEND);
		mailIntent.setType("plain/text");
 
		if(pReceivers != null && pReceivers.length > 0) {
			mailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, pReceivers);
		} 
 
		if(pSubject != null) {
			mailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, pSubject);
		} 
 
		if(pBody != null) {
			mailIntent.putExtra(android.content.Intent.EXTRA_TEXT, pBody);
		} 
 

8
CodeRank
This code example shows how to use the following methods:createChooser
	public void startChooserOrWarn(Intent intent) {
		startChooserOrWarn(intent, null);
	} 
 
	public void startChooserOrWarn(Intent intent, String title) {
		Intent choooserIntent = Intent.createChooser(intent, title);
		startOrWarn(choooserIntent);
	} 
 
	public void startOrWarn(Intent intent) {
		try { 
			ctx.startActivity(intent);
		} catch (ActivityNotFoundException e) {
			L.w(e);
			new AbstractDialogFactory(ctx).showErrorToast();
		} 
	} 
 
	public ActivityInfo[] getIntentHandlers(Intent intent) {
		List<ResolveInfo> list = ctx.getPackageManager().queryIntentActivities(
6
CodeRank
This code example shows how to use the following methods:createChooser, putExtra, setAction, setType
		return relativeTempPath;
	} 
	@Override 
	protected void onPostExecute (String result) {
		if (result != null) {
			final Intent intent = new Intent();
			intent.setAction(Intent.ACTION_SEND);
			intent.setType("image/jpeg");
			intent.putExtra(Intent.EXTRA_STREAM, Uri.parse(result));
			intent.putExtra(Intent.EXTRA_SUBJECT, extraSubject.replaceAll("@comic", mName));
			intent.putExtra(Intent.EXTRA_TEXT, extraText.replaceAll("@comic", mName));
			final Intent chooser = Intent.createChooser(intent, chooserTitle);
			mContext.startActivity(chooser);
		} 
	} 
	 
	public void setChooserTitle(String chooserTitle) {
		this.chooserTitle = chooserTitle;
	} 
	 
8
CodeRank
This code example shows how to use the following methods:createChooser, setAction, setType
public final class MediaStoreUtils { 
    private MediaStoreUtils() { 
    } 
 
    public static Intent getPickImageIntent(final Context context) {
        final Intent intent = new Intent();
        intent.setType("image/*");
        intent.setAction(Intent.ACTION_GET_CONTENT);
 
        return Intent.createChooser(intent, "Select picture");
    } 
 
    public static String getLocalMediaPath(final Context context, final Intent intent) {
        final Uri uri = intent.getData();
        final Cursor cursor = context.getContentResolver().query(uri,
                new String[]{MediaStore.MediaColumns.DATA}, null, null, null);
 
        if (cursor == null) {
            throw new RuntimeException(String.format("Could not resolve file name for url: {0}",
                    uri.toString()));
7
CodeRank
This code example shows how to use the following methods:createChooser, putExtra, setType

Related Intent createChooser Questions & Answers:

createChooser Method Overview
Convenience function for creating a ACTION_CHOOSER Intent.
See Code Examples for other Android Intent Methods: