List of usage examples for android.content Intent createChooser
public static Intent createChooser(Intent target, CharSequence title)
From source file:com.enadein.carlogbook.ui.AboutFragment.java
public void sendEmail(String subject) { Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", getString(R.string.email), null)); intent.putExtra(Intent.EXTRA_SUBJECT, subject); startActivity(Intent.createChooser(intent, "Send Email")); }
From source file:com.hybris.mobile.activity.AbstractProductDetailActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { boolean handled = super.onOptionsItemSelected(item); if (!handled) { // Put custom menu items handlers here switch (item.getItemId()) { // NFC writing is for debug use only case R.id.write_tag: if (NFCUtil.canNFC(this)) { Intent writeIntent = new Intent(this, NFCWriteActivity.class); NdefMessage msg = getNDEF(mProduct.getCode()); writeIntent.putExtra(NFCWriteActivity.NDEF_MESSAGE, msg); startActivity(writeIntent); } else { Toast.makeText(this, R.string.error_nfc_not_supported, Toast.LENGTH_LONG).show(); }/*from w w w. jav a 2 s. c o m*/ return true; case R.id.share: try { Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_TEXT, mProduct.getName() + " - " + getString(R.string.nfc_url, URLEncoder.encode(mProduct.getCode(), "UTF-8"))); sendIntent.setType("text/plain"); startActivity(Intent.createChooser(sendIntent, getString(R.string.share_dialog_title))); } catch (UnsupportedEncodingException e) { LoggingUtils.e(LOG_TAG, "Error trying to encode product code to UTF-8. " + e.getLocalizedMessage(), Hybris.getAppContext()); } return true; default: return false; } } return handled; }
From source file:com.cryart.sabbathschool.util.SSNotification.java
public static void showLessonNotification(Context context) { SSCore _SSCore = SSCore.getInstance(context); if (!SSCore.databaseExists()) return;/*from www.j a va 2s . c o m*/ try { SSDay _SSDay = _SSCore.ssGetDay(_SSCore.ssTodaysDate()); Bitmap _SSLessonBitmap = SSHelper.getBitmapFromBase64(_SSDay._lesson_image); NotificationManager _SSNotificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); Intent _SSContentIntent = new Intent(context, SSLoadingActivity.class); Intent _SSShareIntent = new Intent(); ByteArrayOutputStream bytes = new ByteArrayOutputStream(); String _SSBitmapLocation = Environment.getExternalStorageDirectory().toString() + "/" + SSConstants.SS_NOTIFICATION_LESSON_HERO_TMP_FILENAME; _SSContentIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); _SSShareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); _SSShareIntent.setAction(Intent.ACTION_SEND); _SSShareIntent.putExtra(Intent.EXTRA_TEXT, _SSDay._day_name + " " + SSConstants.SS_SHARE_FB_LINK); _SSLessonBitmap.compress(Bitmap.CompressFormat.PNG, 100, bytes); File f = new File(_SSBitmapLocation); try { f.createNewFile(); FileOutputStream fo = new FileOutputStream(f); fo.write(bytes.toByteArray()); } catch (IOException e) { e.printStackTrace(); } _SSShareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + _SSBitmapLocation)); _SSShareIntent.setType("*/*"); PendingIntent _SSPendingContentIntent = PendingIntent.getActivity(context, 0, _SSContentIntent, PendingIntent.FLAG_CANCEL_CURRENT); PendingIntent _SSPendingShareIntent = PendingIntent.getActivity(context, 0, Intent.createChooser(_SSShareIntent, "Share lesson to:"), PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Builder _SSNotificationBuilder = new NotificationCompat.Builder(context) .setSmallIcon(R.drawable.ss_app_icon_notification) .setColor(context.getResources().getColor(R.color.ss_primary)).setLargeIcon(_SSLessonBitmap) .setContentTitle(_SSDay._day_name) .setStyle(new NotificationCompat.BigPictureStyle().setBigContentTitle(_SSDay._day_name) .setSummaryText(_SSDay._day_name).bigPicture(_SSLessonBitmap)) .addAction(R.drawable.ss_ic_book_grey600_24dp, context.getString(R.string.ss_notification_read_lesson), _SSPendingContentIntent) .addAction(R.drawable.ss_ic_share_white_24dp, context.getString(R.string.ss_notification_share_lesson), _SSPendingShareIntent) .setAutoCancel(true).setContentIntent(_SSPendingContentIntent).setContentText(_SSDay._day_name); _SSNotificationManager.notify(1, _SSNotificationBuilder.build()); } catch (Exception e) { } }
From source file:ayushi.view.fragment.ContactUsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.frag_about, container, false); getActivity().setTitle("Contact Us"); mToolbar = (Toolbar) rootView.findViewById(R.id.htab_toolbar); if (mToolbar != null) { ((ECartHomeActivity) getActivity()).setSupportActionBar(mToolbar); }//w w w .j a va 2s. c o m if (mToolbar != null) { ((ECartHomeActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true); mToolbar.setNavigationIcon(R.drawable.ic_drawer); } mToolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ((ECartHomeActivity) getActivity()).getmDrawerLayout().openDrawer(GravityCompat.START); } }); mToolbar.setTitleTextColor(Color.WHITE); rootView.findViewById(R.id.locations).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { } }); rootView.findViewById(R.id.contact_num).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent callIntent = new Intent(Intent.ACTION_DIAL); callIntent.setData(Uri.parse("tel:" + "8888813275")); startActivity(callIntent); } }); rootView.setFocusableInTouchMode(true); rootView.requestFocus(); rootView.setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK) { Utils.switchContent(R.id.frag_container, Utils.HOME_FRAGMENT, ((ECartHomeActivity) (getContext())), AnimationType.SLIDE_UP); } return true; } }); rootView.findViewById(R.id.site_dev).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://hiteshsahu.com/")); startActivity(browserIntent); } }); rootView.findViewById(R.id.email).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType("text/plain"); emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { "hiteshkumarsahu1990@gmail.com" }); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Hello There"); emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Add Message here"); emailIntent.setType("message/rfc822"); try { startActivity(Intent.createChooser(emailIntent, "Send email using...")); } catch (android.content.ActivityNotFoundException ex) { Toast.makeText(getActivity(), "No email clients installed.", Toast.LENGTH_SHORT).show(); } } }); return rootView; }
From source file:ch.berta.fabio.popularmovies.presentation.ui.fragments.MovieDetailsBaseFragment.java
private void shareYoutubeUrl() { startActivity(Intent.createChooser(mShareYoutubeIntent, getString(R.string.action_share))); }
From source file:edu.mit.mobile.android.demomode.Preferences.java
private void shareConfig() { startActivity(Intent.createChooser( new Intent(Intent.ACTION_SEND).setType("text/plain").putExtra(Intent.EXTRA_TEXT, toConfigString()) .putExtra(Intent.EXTRA_SUBJECT, getText(R.string.app_name) + " Config"), getText(R.string.share_config))); }
From source file:codepath.watsiapp.utils.Util.java
public static void startShareIntent(Activity activity, ShareableItem patient) { Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); shareIntent.putExtra(Intent.EXTRA_TEXT, patient.getShareableUrl()); shareIntent.setType("text/plain"); shareIntent.putExtra(Intent.EXTRA_SUBJECT, "Fund Treatment"); activity.startActivity(Intent.createChooser(shareIntent, "Share Story")); }
From source file:com.Bhailal_Chauhan.retailapp.view.fragment.ContactUsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.frag_about, container, false); getActivity().setTitle("Contact Us"); mToolbar = (Toolbar) rootView.findViewById(R.id.htab_toolbar); if (mToolbar != null) { ((ECartHomeActivity) getActivity()).setSupportActionBar(mToolbar); }/*from www . j a v a 2 s . co m*/ if (mToolbar != null) { ((ECartHomeActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true); mToolbar.setNavigationIcon(R.drawable.ic_drawer); } mToolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ((ECartHomeActivity) getActivity()).getmDrawerLayout().openDrawer(GravityCompat.START); } }); mToolbar.setTitleTextColor(Color.WHITE); rootView.findViewById(R.id.locations).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { } }); rootView.findViewById(R.id.contact_num).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent callIntent = new Intent(Intent.ACTION_DIAL); callIntent.setData(Uri.parse("tel:" + "8347337366")); startActivity(callIntent); } }); rootView.setFocusableInTouchMode(true); rootView.requestFocus(); rootView.setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK) { Utils.switchContent(R.id.frag_container, Utils.HOME_FRAGMENT, ((ECartHomeActivity) (getContext())), AnimationType.SLIDE_UP); } return true; } }); rootView.findViewById(R.id.site_dev).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://bhailalchauhan.com/")); startActivity(browserIntent); } }); rootView.findViewById(R.id.email).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType("text/plain"); emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { "hibhailal458@gmail.com" }); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Hello There"); emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Add Message here"); emailIntent.setType("message/rfc822"); try { startActivity(Intent.createChooser(emailIntent, "Send email using...")); } catch (android.content.ActivityNotFoundException ex) { Toast.makeText(getActivity(), "No email clients installed.", Toast.LENGTH_SHORT).show(); } } }); return rootView; }
From source file:com.cerema.cloud2.files.FileOperationsHelper.java
public void openFile(OCFile file) { if (file != null) { String storagePath = file.getStoragePath(); String encodedStoragePath = WebdavUtils.encodePath(storagePath); Intent intentForSavedMimeType = new Intent(Intent.ACTION_VIEW); intentForSavedMimeType.setDataAndType(Uri.parse("file://" + encodedStoragePath), file.getMimetype()); intentForSavedMimeType/*from ww w. jav a 2s. co m*/ .setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); Intent intentForGuessedMimeType = null; if (storagePath.lastIndexOf('.') >= 0) { String guessedMimeType = MimeTypeMap.getSingleton() .getMimeTypeFromExtension(storagePath.substring(storagePath.lastIndexOf('.') + 1)); if (guessedMimeType != null && !guessedMimeType.equals(file.getMimetype())) { intentForGuessedMimeType = new Intent(Intent.ACTION_VIEW); intentForGuessedMimeType.setDataAndType(Uri.parse("file://" + encodedStoragePath), guessedMimeType); intentForGuessedMimeType.setFlags( Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); } } Intent openFileWithIntent; if (intentForGuessedMimeType != null) { openFileWithIntent = intentForGuessedMimeType; } else { openFileWithIntent = intentForSavedMimeType; } List<ResolveInfo> launchables = mFileActivity.getPackageManager() .queryIntentActivities(openFileWithIntent, PackageManager.GET_INTENT_FILTERS); if (launchables != null && launchables.size() > 0) { try { mFileActivity.startActivity(Intent.createChooser(openFileWithIntent, mFileActivity.getString(R.string.actionbar_open_with))); } catch (ActivityNotFoundException anfe) { showNoAppForFileTypeToast(mFileActivity.getApplicationContext()); } } else { showNoAppForFileTypeToast(mFileActivity.getApplicationContext()); } } else { Log_OC.wtf(TAG, "Trying to open a NULL OCFile"); } }
From source file:com.comrella.webcomics.navigation.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); if (id == R.id.action_settings) { Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_TEXT, "Get Cheesy Funny Comic Strips on your Android Device. Find us on Play Store! www.comrella.com"); sendIntent.setType("text/plain"); startActivity(Intent.createChooser(sendIntent, getResources().getText(R.string.share_app_title))); }//from w w w . j av a 2 s . c om return super.onOptionsItemSelected(item); }