List of usage examples for android.content Intent createChooser
public static Intent createChooser(Intent target, CharSequence title)
From source file:com.richtodd.android.quiltdesign.app.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { int itemId = item.getItemId(); switch (itemId) { case R.id.menu_settings: { Intent intent = new Intent(this, MainPreferenceActivity.class); startActivity(intent);//from w ww . ja v a 2s .c o m return true; } case R.id.menu_about: { TextDialogFragment dialog = TextDialogFragment.create("About Quilt Design", getString(R.string.about), "Close"); dialog.show(getFragmentManager(), null); return true; } case R.id.menu_help: { // Intent intent = new Intent(this, BrowserActivity.class); // intent.putExtra(BrowserActivity.ARG_URL, // "http://quiltdesign.richtodd.com"); Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://quiltdesign.richtodd.com")); startActivity(intent); return true; } case R.id.menu_backup: { Uri uriFile; try { uriFile = saveRepository(); Intent intent = new Intent(Intent.ACTION_SEND); intent.putExtra(Intent.EXTRA_STREAM, uriFile); intent.setType("application/vnd.richtodd.quiltdesign"); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); startActivity(Intent.createChooser(intent, "Backup")); } catch (RepositoryException e) { Handle.asRuntimeError(e); } return true; } case R.id.menu_loadSamples: { SampleLoaderTask task = new SampleLoaderTask(); setSampleLoaderTask(task); task.execute(this); return true; } } return super.onOptionsItemSelected(item); }
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);//from w ww . j a va 2 s .com 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.elekso.potfix.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); PowerManager pm = (PowerManager) getApplicationContext() .getSystemService(getApplicationContext().POWER_SERVICE); PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, " POTFIX holding wake lock"); wl.acquire();/*from ww w. j a v a 2s .c o m*/ Globals.getInstance().setFlexiblemap(true); // // // new Thread(new Runnable(){ // @Override // public void run() { // try { // LALpotfixservicePortBinding service = new LALpotfixservicePortBinding(); // try { // globaldata_test=service.CheckWS("mandar"); // // } catch (Exception e) { // e.printStackTrace(); // } // } catch (Exception ex) { // ex.printStackTrace(); // } // } // }).start(); String login = ""; // Config.getInstance(getBaseContext(),getCacheDir()).setProfile("df","asd"); login = Config.getInstance(getBaseContext(), getCacheDir()).getProfileName(); if (login == null || login.isEmpty()) { Intent intent = new Intent(this, LoginActivity.class); startActivity(intent); return; } //remove // Stetho.initializeWithDefaults(this); // Toolbar Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); // Drawer drawer = (DrawerLayout) findViewById(R.id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawer.setDrawerListener(toggle); toggle.syncState(); tusername = (TextView) drawer.findViewById(R.id.tvusername); // tuseremail =(TextView) findViewById(R.id.tvuseremail); // // if(login!=null) // tusername.setText("jhjhjhjh"); // if(Config.getInstance().getProfileEmail()!=null) //tuseremail.setText(Config.getInstance().getProfileEmail()); // FAB fab = (FloatingActionButton) findViewById(R.id.fab); fab.setRippleColor(Color.parseColor("#78D6F3")); fab.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#039FDC"))); fab.setImageResource(R.drawable.ic_gps_fixed_white_24dp); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { switch (currentFragment) { case 1: //profile Snackbar.make(view, "Updating Information", Snackbar.LENGTH_LONG).setAction("Action", null) .show(); Fragment frg = new ProfileFragment(); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.replace(R.id.frame_containerone, frg); transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); transaction.commit(); break; case 2: //map if (Globals.getInstance().getFlexiblemap()) { Snackbar.make(view, "Free to Scroll", Snackbar.LENGTH_LONG).setAction("Action", null) .show(); Globals.getInstance().setFlexiblemap(false); fab.setRippleColor(Color.parseColor("#FFE082")); fab.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#FFB300"))); fab.setImageResource(R.drawable.ic_gps_off_white_24dp); } else { Snackbar.make(view, "Follow Potfix", Snackbar.LENGTH_LONG).setAction("Action", null).show(); Globals.getInstance().setFlexiblemap(true); fab.setRippleColor(Color.parseColor("#78D6F3")); fab.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#039FDC"))); fab.setImageResource(R.drawable.ic_gps_fixed_white_24dp); } break; case 3: //share //Snackbar.make(view, "Some sharing action", Snackbar.LENGTH_LONG).setAction("Action", null).show(); String[] TO = { "aziz@potfix.com" }; String[] CC = { "" }; Intent emailIntent = new Intent(Intent.ACTION_SEND); emailIntent.setData(Uri.parse("mailto:")); emailIntent.setType("text/plain"); emailIntent.putExtra(Intent.EXTRA_EMAIL, TO); emailIntent.putExtra(Intent.EXTRA_CC, CC); emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Potfix Communication"); emailIntent.putExtra(Intent.EXTRA_TEXT, "Email message..."); try { startActivity(Intent.createChooser(emailIntent, "Send mail...")); finish(); } catch (android.content.ActivityNotFoundException ex) { Toast.makeText(MainActivity.this, "There is no email client installed.", Toast.LENGTH_SHORT) .show(); } break; case 4: //legal Snackbar.make(view, "Software License", Snackbar.LENGTH_LONG).setAction("Action", null).show(); drawer.openDrawer(Gravity.LEFT); break; } } }); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); startService(new Intent(getBaseContext(), BackgroundService.class)); FragmentTransaction mTransaction = getSupportFragmentManager().beginTransaction(); MapsFragment mFRaFragment = new MapsFragment(); mTransaction.add(R.id.frame_containerone, mFRaFragment); mTransaction.commit(); LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE); if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) { Toast.makeText(this, "GPS is Enabled in your devide", Toast.LENGTH_SHORT).show(); } else { showGPSDisabledAlertToUser(); } // if (locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)){ // Toast.makeText(this, "Network is Enabled in your devide", Toast.LENGTH_SHORT).show(); // }else{ // showNetDisabledAlertToUser(); // } createNotification(); }
From source file:com.architjn.materialicons.ui.fragments.HomeFragment.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(); //noinspection SimplifiableIfStatement if (id == android.R.id.home) { drawer.openDrawer(Gravity.LEFT); }/*from w w w. j av a 2 s . com*/ if (id == R.id.action_sendemail) { StringBuilder emailBuilder = new StringBuilder(); Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("mailto:" + getResources().getString(R.string.email_id))); intent.putExtra(Intent.EXTRA_SUBJECT, getResources().getString(R.string.email_subject)); emailBuilder.append("\n \n \nOS Version: ").append(System.getProperty("os.version")).append("(") .append(Build.VERSION.INCREMENTAL).append(")"); emailBuilder.append("\nOS API Level: ").append(Build.VERSION.SDK_INT); emailBuilder.append("\nDevice: ").append(Build.DEVICE); emailBuilder.append("\nManufacturer: ").append(Build.MANUFACTURER); emailBuilder.append("\nModel (and Product): ").append(Build.MODEL).append(" (").append(Build.PRODUCT) .append(")"); PackageInfo appInfo = null; try { appInfo = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0); } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } assert appInfo != null; emailBuilder.append("\nApp Version Name: ").append(appInfo.versionName); emailBuilder.append("\nApp Version Code: ").append(appInfo.versionCode); intent.putExtra(Intent.EXTRA_TEXT, emailBuilder.toString()); startActivity(Intent.createChooser(intent, (getResources().getString(R.string.send_title)))); return true; } else if (id == R.id.action_share) { Intent sharingIntent = new Intent(Intent.ACTION_SEND); sharingIntent.setType("text/plain"); String shareBody = getResources().getString(R.string.share_one) + getResources().getString(R.string.developer_name) + getResources().getString(R.string.share_two) + MARKET_URL + getActivity().getPackageName(); sharingIntent.putExtra(Intent.EXTRA_TEXT, shareBody); startActivity(Intent.createChooser(sharingIntent, (getResources().getString(R.string.share_title)))); } else if (id == R.id.action_changelog) { showChangelog(); } return super.onOptionsItemSelected(item); }
From source file:com.z.stproperty.PropertyDetailFragment.java
/** * onClick :: OnClickListener/*w w w .j a v a 2 s. c om*/ * * 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); } }
From source file:ca.rmen.android.networkmonitor.app.log.LogActionsActivity.java
/** * Run the given file export, then bring up the chooser intent to share the exported file. *///from w w w. j a v a 2s.c o m private void shareFile(final FileExport fileExport) { Log.v(TAG, "shareFile " + fileExport); // Use a horizontal progress bar style if we can show progress of the export. String dialogMessage = getString(R.string.export_progress_preparing_export); int dialogStyle = fileExport != null ? ProgressDialog.STYLE_HORIZONTAL : ProgressDialog.STYLE_SPINNER; DialogFragmentFactory.showProgressDialog(this, dialogMessage, dialogStyle, PROGRESS_DIALOG_TAG); AsyncTask<Void, Void, File> asyncTask = new AsyncTask<Void, Void, File>() { @Override protected File doInBackground(Void... params) { File file = null; if (fileExport != null) { if (!Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) return null; try { // Export the file in the background. file = fileExport.export(); } catch (Throwable t) { Log.e(TAG, "Error exporting file " + fileExport + ": " + t.getMessage(), t); } if (file == null) return null; } String reportSummary = SummaryExport.getSummary(LogActionsActivity.this); // Bring up the chooser to share the file. Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.export_subject_send_log)); String dateRange = SummaryExport.getDataCollectionDateRange(LogActionsActivity.this); String messageBody = getString(R.string.export_message_text, dateRange); if (file != null) { sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + file.getAbsolutePath())); sendIntent.setType("message/rfc822"); messageBody += getString(R.string.export_message_text_file_attached); } else { sendIntent.setType("text/plain"); } messageBody += reportSummary; sendIntent.putExtra(Intent.EXTRA_TEXT, messageBody); startActivity(Intent.createChooser(sendIntent, getResources().getText(R.string.action_share))); return file; } @Override protected void onPostExecute(File result) { super.onPostExecute(result); DialogFragment fragment = (DialogFragment) getSupportFragmentManager() .findFragmentByTag(PROGRESS_DIALOG_TAG); if (fragment != null) fragment.dismissAllowingStateLoss(); // Show a toast if we failed to export a file. if (fileExport != null && result == null) Toast.makeText(LogActionsActivity.this, R.string.export_error_sdcard_unmounted, Toast.LENGTH_LONG).show(); finish(); } }; asyncTask.execute(); }
From source file:im.delight.android.commons.Social.java
/** * Displays an application chooser and composes the described text message (SMS) using the selected application * * @param recipientPhone the recipient's phone number or `null` * @param bodyText the body text of the message * @param captionRes a string resource ID for the title of the application chooser's window * @param context a context reference//from w ww. j a v a2 s . c o m * @throws Exception if there was an error trying to launch the SMS application */ public static void sendSms(final String recipientPhone, final String bodyText, final int captionRes, final Context context) throws Exception { final Intent intent = new Intent(Intent.ACTION_SENDTO); intent.setType(HTTP.PLAIN_TEXT_TYPE); if (recipientPhone != null && recipientPhone.length() > 0) { intent.setData(Uri.parse("smsto:" + recipientPhone)); } else { intent.setData(Uri.parse("sms:")); } intent.putExtra("sms_body", bodyText); intent.putExtra(Intent.EXTRA_TEXT, bodyText); if (context != null) { // offer a selection of all applications that can handle the SMS Intent context.startActivity(Intent.createChooser(intent, context.getString(captionRes))); } }
From source file:com.dwdesign.tweetings.fragment.BaseUserListsListFragment.java
@Override public boolean onMenuItemClick(final MenuItem item) { if (mSelectedUserList == null) return false; switch (item.getItemId()) { case MENU_VIEW_USER_LIST: { openUserListDetails(getActivity(), mAccountId, mSelectedUserList.list_id, mSelectedUserList.user_id, mSelectedUserList.user_screen_name, mSelectedUserList.name); break;//ww w.j a v a 2 s. c o m } case MENU_EXTENSIONS: { final Intent intent = new Intent(INTENT_ACTION_EXTENSION_OPEN_USER_LIST); final Bundle extras = new Bundle(); extras.putParcelable(INTENT_KEY_USER_LIST, mSelectedUserList); intent.putExtras(extras); startActivity(Intent.createChooser(intent, getString(R.string.open_with_extensions))); break; } } return true; }
From source file:ca.rmen.android.poetassistant.main.reader.ReaderFragment.java
@Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == R.id.action_new) { ConfirmDialogFragment.show(ACTION_FILE_NEW, getString(R.string.file_new_confirm_title), getString(R.string.action_clear), getChildFragmentManager(), DIALOG_TAG); } else if (item.getItemId() == R.id.action_open) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) open();/* w ww .ja v a 2s. co m*/ } else if (item.getItemId() == R.id.action_save) { PoemFile poemFile = mPoemPrefs.getSavedPoem(); PoemFile.save(getActivity(), poemFile.uri, mBinding.tvText.getText().toString(), this); } else if (item.getItemId() == R.id.action_save_as) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) saveAs(); } else if (item.getItemId() == R.id.action_share) { Intent intent = new Intent(Intent.ACTION_SEND); intent.putExtra(Intent.EXTRA_TEXT, mBinding.tvText.getText().toString()); intent.setType("text/plain"); startActivity(Intent.createChooser(intent, getString(R.string.share))); } return true; }
From source file:au.com.wallaceit.reddinator.ViewRedditActivity.java
public void shareText(String txt) { Intent sendintent = new Intent(Intent.ACTION_SEND); sendintent.setAction(Intent.ACTION_SEND); sendintent.putExtra(Intent.EXTRA_TEXT, txt); sendintent.setType("text/plain"); startActivity(Intent.createChooser(sendintent, "Share Url to...")); }