List of usage examples for android.content Intent createChooser
public static Intent createChooser(Intent target, CharSequence title)
From source file:com.example.android.naradaonline.DatagramFragment.java
protected final void sendEmail(DatagramRequest data) { if (data.type != DatagramRequestType.SEND_EMAIL) { Log.w(TAG, "This datagram is actually of type " + data.type.name()); }// w w w.j av a2 s . c o m Log.i("Send email", ""); String[] TO = { data.mEmailTo }; 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_SUBJECT, "Your Datagram"); emailIntent.putExtra(Intent.EXTRA_TEXT, data.mEmailBody); try { startActivity(Intent.createChooser(emailIntent, "Send mail...")); Log.i("Finished sending email...", ""); } catch (android.content.ActivityNotFoundException ex) { // Toast.makeText(MainActivity.this, // "There is no email client installed.", Toast.LENGTH_SHORT).show(); } }
From source file:com.android.music.ArtistAlbumBrowserFragment.java
void doSearch() { CharSequence title = null;//w w w . j av a2 s . c om String query = null; Intent i = new Intent(); i.setAction(MediaStore.INTENT_ACTION_MEDIA_SEARCH); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); if (mCurrentArtistId != null) { title = mCurrentArtistName; query = mCurrentArtistName; i.putExtra(MediaStore.EXTRA_MEDIA_ARTIST, mCurrentArtistName); i.putExtra(MediaStore.EXTRA_MEDIA_FOCUS, MediaStore.Audio.Artists.ENTRY_CONTENT_TYPE); } else { if (mIsUnknownAlbum) { title = query = mCurrentArtistNameForAlbum; } else { title = query = mCurrentAlbumName; if (!mIsUnknownArtist) { query = query + " " + mCurrentArtistNameForAlbum; } } i.putExtra(MediaStore.EXTRA_MEDIA_ARTIST, mCurrentArtistNameForAlbum); i.putExtra(MediaStore.EXTRA_MEDIA_ALBUM, mCurrentAlbumName); i.putExtra(MediaStore.EXTRA_MEDIA_FOCUS, MediaStore.Audio.Albums.ENTRY_CONTENT_TYPE); } title = getString(R.string.mediasearch, title); i.putExtra(SearchManager.QUERY, query); startActivity(Intent.createChooser(i, title)); }
From source file:de.geeksfactory.opacclient.frontend.AccountFragment.java
@Override public void accountSelected(Account account) { svAccount.setVisibility(View.GONE); unsupportedErrorView.setVisibility(View.GONE); answerErrorView.setVisibility(View.GONE); errorView.removeAllViews();/*ww w . ja v a 2s.c om*/ llLoading.setVisibility(View.VISIBLE); setRefreshing(false); supported = true; this.account = app.getAccount(); OpacApi api; try { api = app.getApi(); } catch (NullPointerException e) { e.printStackTrace(); return; } if (api != null && !app.getLibrary().isAccountSupported()) { supported = false; // Not supported with this api at all llLoading.setVisibility(View.GONE); unsupportedErrorView.setVisibility(View.VISIBLE); tvErrBodyU.setText(R.string.account_unsupported_api); btSend.setText(R.string.write_mail); btSend.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { "info@opacapp.de" }); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Bibliothek " + app.getLibrary().getIdent()); emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, getResources().getString(R.string.interested_to_help)); emailIntent.setType("text/plain"); startActivity(Intent.createChooser(emailIntent, getString(R.string.write_mail))); } }); } else if (account.getPassword() == null || account.getPassword().equals("null") || account.getPassword().equals("") || account.getName() == null || account.getName().equals("null") || account.getName().equals("")) { // No credentials entered llLoading.setVisibility(View.GONE); answerErrorView.setVisibility(View.VISIBLE); btPrefs.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getActivity(), AccountEditActivity.class); intent.putExtra(AccountEditActivity.EXTRA_ACCOUNT_ID, app.getAccount().getId()); startActivity(intent); } }); tvErrHeadA.setText(""); tvErrBodyA.setText(R.string.status_nouser); } else { // Supported Context ctx = getActivity() != null ? getActivity() : OpacClient.getEmergencyContext(); AccountDataSource adatasource = new AccountDataSource(ctx); adatasource.open(); refreshtime = adatasource.getCachedAccountDataTime(account); if (refreshtime > 0) { displaydata(adatasource.getCachedAccountData(account), true); if (System.currentTimeMillis() - refreshtime > MAX_CACHE_AGE) { refresh(); } } else { refresh(); } adatasource.close(); } }
From source file:com.denel.facepatrol.MainActivity.java
public void ContactEmail(View view) { Intent emailIntent = new Intent(Intent.ACTION_SENDTO); emailIntent.setData(Uri.parse("mailto:")); emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { contact_email }); //emailIntent.setType("message/rfc822"); emailIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); startActivity(Intent.createChooser(emailIntent, "Send Email...")); //finish();//from ww w .j ava2 s . c om }
From source file:appteam.nith.hillffair.activities.HomeActivity.java
@SuppressWarnings("StatementWithEmptyBody") @Override//w w w . j ava2 s . c om public boolean onNavigationItemSelected(MenuItem item) { // Handle navigation view item clicks here. int id = item.getItemId(); switch (id) { case R.id.profile: startActivity(new Intent(HomeActivity.this, ProfileActivity.class)); break; case R.id.settings: startActivity(new Intent(HomeActivity.this, SettingsActivity.class)); finish(); break; case R.id.aboutus: AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(String.format("%1$s", getString(R.string.app_name))); builder.setMessage(getResources().getText(R.string.aboutus_text)); builder.setPositiveButton("OK", null); builder.setIcon(R.drawable.ic_action_about); AlertDialog welcomeAlert = builder.create(); welcomeAlert.show(); break; case R.id.report: Intent intent = new Intent(Intent.ACTION_SENDTO); String uriText = "mailto:" + Uri.encode("appteam.nith@gmail.com") + "?subject=" + Uri.encode("Reporting A Bug/Feedback") + "&body=" + Uri.encode( "Hello, Appteam \nI want to report a bug/give feedback corresponding to the app Hillfair 2k16.\n.....\n\n-Your name"); Uri uri = Uri.parse(uriText); intent.setData(uri); startActivity(Intent.createChooser(intent, "Send Email")); break; case R.id.license: AlertDialog.Builder builder2 = new AlertDialog.Builder(this); builder2.setTitle(String.format("%1$s", getString(R.string.open_source_licenses))); CharSequence str = getResources().getText(R.string.licenses_text); builder2.setMessage(str); builder2.setPositiveButton("OK", null); AlertDialog welcomeAlert2 = builder2.create(); welcomeAlert2.show(); ((TextView) welcomeAlert2.findViewById(android.R.id.message)) .setMovementMethod(LinkMovementMethod.getInstance()); break; case R.id.notification: startActivity(new Intent(HomeActivity.this, NotificationActivity.class)); break; case R.id.logout: pref.setUserId(null); pref.setRollNo(null); pref.setUserName(null); startActivity(new Intent(HomeActivity.this, LoginActivity.class)); finish(); break; } DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); drawer.closeDrawer(GravityCompat.START); return true; }
From source file:ca.ualberta.cs.drivr.RequestsListAdapter.java
/** * Called when the view holder is wants to bind the request at a certain position in the list. * @param viewHolder//from ww w . jav a 2 s . c o m * @param position */ @Override public void onBindViewHolder(final RequestsListAdapter.ViewHolder viewHolder, final int position) { final Request request = requestsToDisplay.get(position); // Get the views to update final TextView otherUserNameTextView = viewHolder.otherUserNameTextView; final TextView descriptionTextView = viewHolder.descriptionTextView; final TextView fareTextView = viewHolder.fareTextView; final TextView routeTextView = viewHolder.routeTextView; final TextView statusTextView = viewHolder.statusTextView; final ImageView callImageView = viewHolder.callImageView; final ImageView emailImageView = viewHolder.emailImageView; final ImageView checkImageView = viewHolder.checkMarkImageView; final ImageView deleteImageView = viewHolder.xMarkImageView; // Todo Hide Image Views until correct Request State if (request.getRequestState() != RequestState.CONFIRMED) { checkImageView.setVisibility(View.INVISIBLE); } if (request.getRequestState() != RequestState.PENDING) { deleteImageView.setVisibility(View.INVISIBLE); } // Show the other person's name final DriversList drivers = request.getDrivers(); // Get the username of the other user if (userManager.getUserMode() == UserMode.RIDER) { final String multipleDrivers = "Multiple Drivers Accepted"; final String driverUsername = drivers.size() == 1 ? drivers.get(0).getUsername() : "No Driver Yet"; otherUserNameTextView.setText(drivers.size() > 1 ? multipleDrivers : driverUsername); } else { otherUserNameTextView.setText(request.getRider().getUsername()); } // If the request has a description, show it. Otherwise, hide te description if (Strings.isNullOrEmpty(request.getDescription())) descriptionTextView.setVisibility(View.GONE); else descriptionTextView.setText(request.getDescription()); // Show the fare fareTextView.setText("$" + request.getFareString()); // Show the route routeTextView.setText(request.getRoute()); // Driver User otherUserNameTextView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final String otherUsername = otherUserNameTextView.getText().toString(); // there exists drivers if (otherUsername != "No Driver Yet") { if (otherUsername != "Multiple Drivers Accepted") { Gson gson = new GsonBuilder().registerTypeAdapter(Uri.class, new UriSerializer()).create(); ElasticSearch elasticSearch = new ElasticSearch( UserManager.getInstance().getConnectivityManager()); User user = elasticSearch.loadUser(otherUsername); String driverString = gson.toJson(user, User.class); Intent intent = new Intent(context, DriverProfileActivity.class); intent.putExtra(DriverProfileActivity.DRIVER, driverString); context.startActivity(intent); } else { startMultipleDriverIntent(request); } } } }); routeTextView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Gson gson = new GsonBuilder().registerTypeAdapter(Uri.class, new UriSerializer()).create(); String requestString = gson.toJson(request, Request.class); Intent intent = new Intent(context, RequestActivity.class); intent.putExtra("UniqueID", "From_RequestListActivity"); intent.putExtra(RequestActivity.EXTRA_REQUEST, requestString); context.startActivity(intent); } }); // Show the status text statusTextView.setText(request.getRequestState().toString()); // Add a listener to the call image callImageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (drivers.size() == 0) { Toast.makeText(context, "No driver number available at this time", Toast.LENGTH_SHORT).show(); } // Start Dialer else if (drivers.size() == 1) { Intent intent = new Intent(Intent.ACTION_CALL); String number; if (UserManager.getInstance().getUserMode().equals(UserMode.RIDER)) { number = drivers.get(0).getPhoneNumber(); } else { number = request.getRider().getPhoneNumber(); } number = "tel:" + number; intent.setData(Uri.parse(number)); if (ActivityCompat.checkSelfPermission(context, Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) { return; } context.startActivity(intent); } else { startMultipleDriverIntent(request); } } }); // Add a listener to the email image emailImageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (drivers.size() == 0) { Toast.makeText(context, "No driver email available at this time", Toast.LENGTH_SHORT).show(); } //http://stackoverflow.com/questions/8701634/send-email-intent else if (drivers.size() == 1) { Intent intent = new Intent(); ComponentName emailApp = intent.resolveActivity(context.getPackageManager()); ComponentName unsupportedAction = ComponentName .unflattenFromString("com.android.fallback/.Fallback"); boolean hasEmailApp = emailApp != null && !emailApp.equals(unsupportedAction); String email; if (UserManager.getInstance().getUserMode().equals(UserMode.RIDER)) { email = drivers.get(0).getEmail(); } else { email = request.getRider().getEmail(); } String subject = "Drivr Request: " + request.getId(); String body = "Drivr user " + drivers.get(0).getUsername(); if (hasEmailApp) { Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:" + email)); emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject); emailIntent.putExtra(Intent.EXTRA_TEXT, body); context.startActivity(Intent.createChooser(emailIntent, "Chooser Title")); } else { Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", email, null)); emailIntent.putExtra(Intent.EXTRA_SUBJECT, ""); emailIntent.putExtra(Intent.EXTRA_TEXT, ""); context.startActivity(Intent.createChooser(emailIntent, "Send email...")); } } else { startMultipleDriverIntent(request); } } }); // Complete The Request checkImageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(context, RequestCompletedActivity.class); intent.putExtra(RequestCompletedActivity.REQUEST_ID_EXTRA, request.getId()); context.startActivity(intent); } }); deleteImageView.setOnClickListener(new View.OnClickListener() { // Todo Delete the Request @Override public void onClick(View v) { v.getContext(); ElasticSearch elasticSearch = new ElasticSearch( (ConnectivityManager) v.getContext().getSystemService(Context.CONNECTIVITY_SERVICE)); elasticSearch.deleteRequest(request.getId()); UserManager userManager = UserManager.getInstance(); userManager.getRequestsList().removeById(request); userManager.notifyObservers(); requestsToDisplay.remove(request); notifyItemRemoved(viewHolder.getAdapterPosition()); } }); }
From source file:com.phonegap.plugins.wsiCameraLauncher.WsiCameraLauncher.java
/** * Get image from photo library.//from w w w . j a v a 2 s . com * * @param quality * Compression quality hint (0-100: 0=low quality & high * compression, 100=compress of max quality) * @param srcType * The album to get image from. * @param returnType * Set the type of image to return. */ // TODO: Images selected from SDCARD don't display correctly, but from // CAMERA ALBUM do! public void getImage(int srcType, int returnType) { final int srcTypeFinal = srcType; final int returnTypeFinal = returnType; String[] choices = { "Upload a Photo", "Upload a Video" }; AlertDialog.Builder builder = new AlertDialog.Builder(this.cordova.getActivity()); builder.setItems(choices, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Log.d(LOG_TAG, "Index #" + which + " chosen."); Intent intent = new Intent(); if (which == 0) { // set up photo intent WsiCameraLauncher.this.mediaType = PICTURE; intent.setType("image/*"); } else if (which == 1) { // set up video intent WsiCameraLauncher.this.mediaType = VIDEO; intent.setType("video/*"); } else { WsiCameraLauncher.this.failPicture("Selection cancelled."); return; } intent.setAction(Intent.ACTION_GET_CONTENT); intent.addCategory(Intent.CATEGORY_OPENABLE); if (WsiCameraLauncher.this.cordova != null) { WsiCameraLauncher.this.cordova.startActivityForResult((CordovaPlugin) WsiCameraLauncher.this, Intent.createChooser(intent, new String("Pick")), (srcTypeFinal + 1) * 16 + returnTypeFinal + 1); } } }); builder.setOnKeyListener(new DialogInterface.OnKeyListener() { @Override public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP && !event.isCanceled()) { dialog.cancel(); WsiCameraLauncher.this.failPicture("Selection cancelled."); return true; } return false; } }); builder.show(); }
From source file:com.cypress.cysmart.DataLoggerFragments.DataLoggerFragment.java
/** * Sharing the data logger txt file//from w w w .ja v a 2 s .co m */ private void shareDataLoggerFile() { HomePageActivity.containerView.invalidate(); Intent emailIntent = new Intent(Intent.ACTION_SEND); // set the type to 'email' emailIntent.setType("vnd.android.cursor.dir/email"); emailIntent.putExtra(Intent.EXTRA_EMAIL, ""); // the attachment emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(mFilepath))); // the mail subject emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Data Logger File"); startActivity(Intent.createChooser(emailIntent, "Send email...")); }
From source file:com.brq.wallet.activity.export.BackupToPdfActivity.java
private void sharePdf() { findViewById(R.id.btSharePdf).setEnabled(false); ((TextView) findViewById(R.id.tvStatus)) .setText(getResources().getString(R.string.encrypted_pdf_backup_sharing)); Uri uri = getUri();// w ww . j av a2s . co m String bodyText = getResources().getString(R.string.encrypted_pdf_backup_email_text); Intent intent = ShareCompat.IntentBuilder.from(this).setStream(uri) // uri from FileProvider .setType("application/pdf").setSubject(getSubject()).setText(bodyText).getIntent() .addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); grantPermissions(intent, uri); startActivityForResult(Intent.createChooser(intent, getResources().getString(R.string.share_with)), SHARE_REQUEST_CODE); }
From source file:com.desno365.mods.Activities.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. switch (item.getItemId()) { case android.R.id.home: if (mNavigationDrawerFragment.isDrawerOpen()) MainNavigationDrawerFragment.mDrawerLayout.closeDrawer(findViewById(R.id.navigation_drawer)); else//from w ww .java 2 s . c o m MainNavigationDrawerFragment.mDrawerLayout.openDrawer(findViewById(R.id.navigation_drawer)); return true; case R.id.action_info: startActivity(new Intent(this, AboutActivity.class)); return true; case R.id.action_help: startActivity(new Intent(this, HelpActivity.class)); return true; case R.id.action_news: startActivity(new Intent(this, NewsActivity.class)); return true; case R.id.action_share: Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND); sharingIntent.setType("text/plain"); sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, getString(R.string.share_body)); startActivity(Intent.createChooser(sharingIntent, getResources().getString(R.string.share_using))); DesnoUtils.sendAction(mTracker, "Share"); return true; case R.id.action_feedback: Intent intent = new Intent(Intent.ACTION_SENDTO); intent.setData(Uri.parse("mailto:")); // only email apps should handle this intent.putExtra(Intent.EXTRA_EMAIL, new String[] { "desno365@gmail.com" }); intent.putExtra(Intent.EXTRA_SUBJECT, "Desno365's Mods feedback"); if (intent.resolveActivity(getPackageManager()) != null) { startActivity(intent); } DesnoUtils.sendAction(mTracker, "Feedback"); return true; case R.id.action_rate: final String appPackageName = getPackageName(); try { //play store installed startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName))); } catch (android.content.ActivityNotFoundException anfe) { //play store not installed startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=" + appPackageName))); } DesnoUtils.sendAction(mTracker, "Rate-app"); return true; case R.id.action_settings: Intent intentSettings = new Intent(this, SettingsActivity.class); startActivity(intentSettings); return true; default: return super.onOptionsItemSelected(item); } }