Example usage for android.content Intent createChooser

List of usage examples for android.content Intent createChooser

Introduction

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

Prototype

public static Intent createChooser(Intent target, CharSequence title) 

Source Link

Document

Convenience function for creating a #ACTION_CHOOSER Intent.

Usage

From source file:com.bzu.yhd.pocketcampus.main.AboutActivity.java

@OnClick({ R.id.about_github_img, R.id.about_license_text, R.id.feed_back })
public void onClick(View view) {
    switch (view.getId()) {
    case R.id.about_github_img:
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.setData(Uri.parse(getString(R.string.github_page)));
        startActivity(Intent.createChooser(intent, "?"));
        break;/*from  w ww.ja  v a  2s  . com*/
    case R.id.about_license_text:
        navigateTo(OpenLicenseActivity.class);
        break;
    case R.id.feed_back:
        showToast("????");
        break;
    }
}

From source file:com.manning.androidhacks.hack035.MainActivity.java

public void onPickBoth(View v) {
    Intent pickIntent = new Intent(Intent.ACTION_GET_CONTENT);
    pickIntent.setType("image/*");

    Intent takePhotoIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);

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

    startActivityForResult(chooserIntent, PICK_OR_TAKE_PICTURE);
}

From source file:edu.stanford.mobisocial.dungbeetle.obj.action.ExportPhotoAction.java

@Override
public void onAct(Context context, DbEntryHandler objType, DbObj obj) {
    byte[] raw = obj.getRaw();
    if (raw == null) {
        String b64Bytes = obj.getJson().optString(PictureObj.DATA);
        raw = FastBase64.decode(b64Bytes);
    }//w w w  . j  a  va  2 s.  co  m
    OutputStream outStream = null;
    File file = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/temp_share.png");
    try {
        outStream = new FileOutputStream(file);

        BitmapManager mgr = new BitmapManager(1);
        Bitmap bitmap = mgr.getBitmap(raw.hashCode(), raw);

        bitmap.compress(Bitmap.CompressFormat.PNG, 100, outStream);
        outStream.flush();
        outStream.close();

        bitmap.recycle();
        bitmap = null;
        System.gc();
        Intent intent = new Intent(android.content.Intent.ACTION_SEND);
        intent.setType("image/png");
        Log.w("ResharePhotoAction",
                Environment.getExternalStorageDirectory().getAbsolutePath() + "/temp_share.png");
        intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
        context.startActivity(Intent.createChooser(intent, "Export image to"));

    } catch (Exception e) {
        e.printStackTrace();
    }

}

From source file:com.example.linhdq.test.main_menu.FeedbackActivity.java

@Override
public void onClick(View v) {
    Intent intent;/* w  w w  . j av  a  2  s  . com*/
    switch (v.getId()) {
    case R.id.layout_enroll_beta_test:
    case R.id.button_enroll_beta_test:
        slideOutLeft = true;
        intent = ContactActivity.getBetaTestIntent(this);
        startActivity(intent);
        break;
    case R.id.layout_send_feedback:
    case R.id.button_send_feedback:
        slideOutLeft = true;
        intent = ContactActivity.getFeedbackIntent(getString(R.string.feedback_subject), null);
        startActivity(Intent.createChooser(intent, getString(R.string.feedback_title)));
        break;
    case R.id.layout_rate_app:
    case R.id.button_rate_app:
        slideOutLeft = true;
        overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left);
        intent = new Intent(Intent.ACTION_VIEW);
        Uri url = Uri.parse(MARKET_URL);
        intent.setData(url);
        startActivity(intent);
        break;
    }

}

From source file:com.emartynov.android.app.urlsetter.android.ui.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == R.id.action_about) {
        startActivity(new Intent(this, AboutActivity.class));
        return true;
    } else if (item.getItemId() == R.id.action_feedback) {
        Intent emailIntent = new Intent(Intent.ACTION_SENDTO,
                Uri.fromParts("mailto", "bijdorpstudio@gmail.com", null));
        emailIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.feedback_subject));
        startActivity(Intent.createChooser(emailIntent, getString(R.string.action_feedback)));
        return true;
    } else if (item.getItemId() == R.id.action_resolve_link) {
        FragmentManager fm = getSupportFragmentManager();
        EnterShortenedUrlFragment userInputDialog = new EnterShortenedUrlFragment();
        userInputDialog.show(fm, null);/* w w w . j  a  v  a2  s  .  c o m*/

        return true;
    } else {
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.allen.mediautil.ImageTakerHelper.java

/**
 * ? onActivityResult()?/*from   ww  w. j  a  va 2  s  .c  om*/
 */
public static void openAlbum(Activity activity) {
    Intent intentAlbum = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
    intentAlbum.setType("image/*");
    activity.startActivityForResult(Intent.createChooser(intentAlbum, ""), REQUEST_ALBUM);
}

From source file:com.coinblesk.client.ui.dialogs.ReceiveDialogFragment.java

@Nullable
@Override/*from  w  ww.j ava2  s  .  c o  m*/
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    final String bitcoinUriString = this.getArguments().getString(BITCOIN_URI_KEY);

    try {
        final BitcoinURI bitcoinURI = new BitcoinURI(bitcoinUriString);
        final View view = inflater.inflate(R.layout.fragment_receive_alertdialog, null);
        view.findViewById(R.id.receive_email_touch_area).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
                emailIntent.setType("text/html");
                emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
                        String.format(getString(R.string.payment_request_html_subject)));
                emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,
                        Html.fromHtml(String.format(getString(R.string.payment_request_html_content),
                                bitcoinUriString, bitcoinURI.getAmount().toFriendlyString(),
                                bitcoinURI.getAddress())));
                startActivity(Intent.createChooser(emailIntent, "Email:"));
            }
        });

        view.findViewById(R.id.receive_qrcode_touch_area).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                QrDialogFragment.newInstance(bitcoinURI).show(getFragmentManager(), "qr-fragment");
            }
        });

        view.findViewById(R.id.receive_contactless_touch_area).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent action = new Intent(Constants.START_SERVERS_ACTION);
                action.putExtra(BITCOIN_URI_KEY, bitcoinUriString);
                LocalBroadcastManager.getInstance(getActivity()).sendBroadcast(action);
            }
        });

        return view;
    } catch (BitcoinURIParseException e) {
        Log.e(TAG, "Could not parse Bitcoin URI: ", e);
    }
    return null;
}

From source file:im.delight.android.baselib.Social.java

/**
 * Constructs an Intent for sharing/sending a file and starts Activity chooser for that Intent
 *
 * @param context Context reference to start the Activity chooser from
 * @param windowTitle the string to be used as the window title for the Activity chooser
 * @param file the File instance to be shared
 * @param mimeType the MIME type for the file to be shared (e.g. image/jpeg)
 * @param messageTitle the message title/subject that may be provided in addition to the file, if supported by the target app
 *///from  w ww . j  a  v a  2s  . co  m
public static void shareFile(Context context, String windowTitle, File file, final String mimeType,
        String messageTitle) {
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_SEND);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setType(mimeType);
    intent.putExtra(Intent.EXTRA_SUBJECT, messageTitle);
    intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
    context.startActivity(Intent.createChooser(intent, windowTitle));
}

From source file:com.cryart.sabbathschool.misc.SSReminderService.java

@Override
public boolean onStartJob(JobParameters job) {
    Context context = getBaseContext();
    SSReminder.scheduleAlarms(context);/*from  w  w  w.java  2  s.co  m*/
    try {
        String channelId = "ss_notification_channel";
        String channelName = getString(R.string.app_name);

        NotificationManager _SSNotificationManager = (NotificationManager) context
                .getSystemService(Context.NOTIFICATION_SERVICE);

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            int importance = NotificationManager.IMPORTANCE_HIGH;
            NotificationChannel mChannel = new NotificationChannel(channelId, channelName, importance);
            _SSNotificationManager.createNotificationChannel(mChannel);
        }
        Intent _SSContentIntent = new Intent(context, SSSplashActivity.class);

        Intent _SSShareIntent = new Intent();

        _SSContentIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        _SSShareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        _SSShareIntent.setAction(Intent.ACTION_SEND);
        _SSShareIntent.putExtra(Intent.EXTRA_TEXT, "");

        _SSShareIntent.setType("*/*");

        PendingIntent _SSPendingContentIntent = PendingIntent.getActivity(context, 0, _SSContentIntent,
                PendingIntent.FLAG_CANCEL_CURRENT);
        PendingIntent _SSPendingShareIntent = PendingIntent.getActivity(context, 0,
                Intent.createChooser(_SSShareIntent, context.getString(R.string.ss_share)),
                PendingIntent.FLAG_UPDATE_CURRENT);

        NotificationCompat.Builder _SSNotificationBuilder = new NotificationCompat.Builder(context,
                "ss_notification_channel").setSmallIcon(R.mipmap.ic_stat_notification)
                        .setContentTitle(context.getString(R.string.ss_app_name))
                        .setColor(Color.parseColor(SSColorTheme.getInstance().getColorPrimary()))
                        .addAction(0, context.getString(R.string.ss_menu_read_now), _SSPendingContentIntent)
                        .addAction(0, context.getString(R.string.ss_share), _SSPendingShareIntent)
                        .setAutoCancel(true).setVibrate(new long[] { 1000, 1000 })
                        .setContentIntent(_SSPendingContentIntent)
                        .setContentText(context.getString(R.string.ss_settings_reminder_text));

        _SSNotificationManager.notify(1, _SSNotificationBuilder.build());
    } catch (Exception e) {
        Crashlytics.log(e.getMessage());
    }

    return false; // Answers the question: "Is there still work going on?"
}

From source file:com.example.linhdq.test.main_menu.ContactActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_contact);
    initToolbar();/*  w ww .jav a  2s.c o  m*/
    setToolbarMessage(R.string.pref_title_contact);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    TextView email = (TextView) findViewById(R.id.textView_send_mail);
    email.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent intent = getFeedbackIntent(getString(R.string.feedback_subject), null);
            startActivity(Intent.createChooser(intent, getString(R.string.feedback_title)));
        }
    });
}