List of usage examples for android.content Intent ACTION_SENDTO
String ACTION_SENDTO
To view the source code for android.content Intent ACTION_SENDTO.
Click Source Link
From source file:de.tum.in.tumcampus.fragments.SettingsFragment.java
/** * Handle all clicks on 'button'-preferences * * @param preference Preference that has been clicked * @return True, if handled/*from w w w. j a v a2s . c o m*/ */ @Override public boolean onPreferenceClick(Preference preference) { final String key = preference.getKey(); switch (key) { case "button_wizard": mContext.finish(); startActivity(new Intent(mContext, WizNavStartActivity.class)); break; case "button_clear_cache": // This button invokes the clear cache method new AlertDialog.Builder(mContext).setMessage(R.string.delete_chache_sure) .setPositiveButton(R.string.yes, new Dialog.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { clearCache(); } }).setNegativeButton(R.string.no, null).show(); break; case "facebook": // Open the facebook app or view in a browser when not installed Intent facebook; try { //Try to get facebook package to check if fb app is installed mContext.getPackageManager().getPackageInfo("com.facebook.katana", 0); facebook = new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.facebook_link_app))); } catch (Exception e) { //otherwise just open the normal url facebook = new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.facebook_link))); } startActivity(facebook); break; case "github": // Open TCA-github web page startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.github_link)))); break; case "first_run": // Show first use tutorial SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mContext); SharedPreferences.Editor e = prefs.edit(); e.putBoolean(CardManager.SHOW_TUTORIAL_1, true); e.putBoolean(CardManager.SHOW_TUTORIAL_2, true); e.apply(); CardManager.update(mContext); startActivity(new Intent(mContext, MainActivity.class)); break; case "licenses": // Show licences new LicensesDialog.Builder(mContext).setNotices(R.raw.notices).setShowFullLicenseText(false) .setIncludeOwnLicense(true).build().show(); break; case "feedback": /* Create the Intent */ Uri uri = Uri.parse("mailto:tca-support.os.in@tum.de?subject=" + getString(R.string.feedbackSubj)); Intent sendIntent = new Intent(Intent.ACTION_SENDTO); sendIntent.setData(uri); /* Send it off to the Activity-Chooser */ startActivity(Intent.createChooser(sendIntent, getString(R.string.send_email))); break; case "privacy": Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.url_privacy_policy))); startActivity(myIntent); break; default: return false; } return true; }
From source file:appteam.nith.hillffair.activities.HomeActivity.java
@SuppressWarnings("StatementWithEmptyBody") @Override/*from www . j av a 2s.c o m*/ 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: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 . ja v a2 s. c o m*/ }
From source file:net.olejon.mdapp.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Settings//ww w. j av a 2s . c o m PreferenceManager.setDefaultValues(mContext, R.xml.settings, false); // Installed long installed = mTools.getSharedPreferencesLong("INSTALLED"); if (installed == 0) mTools.setSharedPreferencesLong("INSTALLED", mTools.getCurrentTime()); // Input manager mInputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); // Layout setContentView(R.layout.activity_main); // Toolbar final Toolbar toolbar = (Toolbar) findViewById(R.id.main_toolbar); toolbar.setTitle(getString(R.string.main_title)); setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_menu_white_24dp); // Search mSearchEditText = (EditText) findViewById(R.id.main_search_edittext); // Drawer mDrawer = (LinearLayout) findViewById(R.id.main_drawer); mDrawerLayout = (DrawerLayout) findViewById(R.id.main_drawer_layout); TextView drawerVersionNameTextView = (TextView) findViewById(R.id.drawer_version_name); TextView drawerVersionCodeTextView = (TextView) findViewById(R.id.drawer_version_code); drawerVersionNameTextView .setText(getString(R.string.drawer_version_name) + ": " + mTools.getProjectVersionName()); drawerVersionCodeTextView .setText(getString(R.string.drawer_version_code) + ": " + mTools.getProjectVersionCode()); mDrawerLayout.setDrawerListener(new ActionBarDrawerToggle(this, mDrawerLayout, toolbar, R.string.project_name, R.string.project_name)); mDrawerLayout.setDrawerListener(new ActionBarDrawerToggle(this, mDrawerLayout, toolbar, R.string.drawer_content_description, R.string.drawer_content_description) { @Override public void onDrawerOpened(View drawerView) { mDrawerClosed = 0; } @Override public void onDrawerClosed(View drawerView) { TextView brukerhandbokenTextView = (TextView) findViewById(R.id.drawer_item_brukerhandboken); TextView analyseoversiktenTextView = (TextView) findViewById(R.id.drawer_item_analyseoversikten); TextView upToDateTextView = (TextView) findViewById(R.id.drawer_item_uptodate); TextView bmjTextView = (TextView) findViewById(R.id.drawer_item_bmj); TextView encyclopediasTextView = (TextView) findViewById(R.id.drawer_item_encyclopedias); brukerhandbokenTextView.setVisibility(View.GONE); analyseoversiktenTextView.setVisibility(View.GONE); upToDateTextView.setVisibility(View.GONE); bmjTextView.setVisibility(View.GONE); encyclopediasTextView.setVisibility(View.VISIBLE); switch (mDrawerClosed) { case R.id.drawer_item_nlh: { Intent intent = new Intent(mContext, MainWebViewActivity.class); intent.putExtra("title", getString(R.string.drawer_item_nlh)); intent.putExtra("uri", "http://m.legemiddelhandboka.no/"); startActivity(intent); break; } case R.id.drawer_item_felleskatalogen: { Intent intent = new Intent(mContext, MainWebViewActivity.class); intent.putExtra("title", getString(R.string.drawer_item_felleskatalogen)); intent.putExtra("uri", "http://www.felleskatalogen.no/m/medisin/"); startActivity(intent); break; } case R.id.drawer_item_brukerhandboken: { Intent intent = new Intent(mContext, MainWebViewActivity.class); intent.putExtra("title", getString(R.string.drawer_item_brukerhandboken)); intent.putExtra("uri", "http://brukerhandboken.no/"); startActivity(intent); break; } case R.id.drawer_item_analyseoversikten: { Intent intent = new Intent(mContext, MainWebViewActivity.class); intent.putExtra("title", getString(R.string.drawer_item_analyseoversikten)); intent.putExtra("uri", "http://www.analyseoversikten.no/"); startActivity(intent); break; } case R.id.drawer_item_uptodate: { Intent intent = new Intent(mContext, MainWebViewActivity.class); intent.putExtra("title", getString(R.string.drawer_item_uptodate)); intent.putExtra("uri", "http://www.uptodate.com/contents/search"); startActivity(intent); break; } case R.id.drawer_item_bmj: { Intent intent = new Intent(mContext, MainWebViewActivity.class); intent.putExtra("title", getString(R.string.drawer_item_bmj)); intent.putExtra("uri", "http://bestpractice.bmj.com/"); startActivity(intent); break; } case R.id.drawer_item_diseases_and_treatments: { Intent intent = new Intent(mContext, DiseasesAndTreatmentsActivity.class); startActivity(intent); break; } case R.id.drawer_item_lvh: { Intent intent = new Intent(mContext, LvhActivity.class); startActivity(intent); break; } case R.id.drawer_item_interactions: { Intent intent = new Intent(mContext, InteractionsActivity.class); startActivity(intent); break; } case R.id.drawer_item_poisonings: { Intent intent = new Intent(mContext, PoisoningsActivity.class); startActivity(intent); break; } case R.id.drawer_item_nasjonale_retningslinjer: { Intent intent = new Intent(mContext, NasjonaleRetningslinjerActivity.class); startActivity(intent); break; } case R.id.drawer_item_clinicaltrials: { Intent intent = new Intent(mContext, ClinicalTrialsActivity.class); startActivity(intent); break; } case R.id.drawer_item_atc: { Intent intent = new Intent(mContext, AtcActivity.class); startActivity(intent); break; } case R.id.drawer_item_icd10: { Intent intent = new Intent(mContext, Icd10Activity.class); startActivity(intent); break; } case R.id.drawer_item_manufacturers: { Intent intent = new Intent(mContext, ManufacturersActivity.class); startActivity(intent); break; } case R.id.drawer_item_pharmacies: { Intent intent = new Intent(mContext, PharmaciesActivity.class); startActivity(intent); break; } case R.id.drawer_item_scales: { Intent intent = new Intent(mContext, ScalesActivity.class); startActivity(intent); break; } case R.id.drawer_item_notifications_from_slv: { Intent intent = new Intent(mContext, NotificationsFromSlvActivity.class); startActivity(intent); break; } case R.id.drawer_item_calculators: { Intent intent = new Intent(mContext, CalculatorsActivity.class); startActivity(intent); break; } case R.id.drawer_item_notes: { Intent intent = new Intent(mContext, NotesActivity.class); startActivity(intent); break; } case R.id.drawer_item_tasks: { Intent intent = new Intent(mContext, TasksActivity.class); startActivity(intent); break; } case R.id.drawer_item_settings: { Intent intent = new Intent(mContext, SettingsActivity.class); startActivity(intent); break; } case R.id.drawer_item_donate: { Intent intent = new Intent(mContext, DonateActivity.class); startActivity(intent); break; } case R.id.drawer_item_feedback: { Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:" + getString(R.string.project_feedback_uri) + "?subject=" + getString(R.string.project_name))); startActivity(Intent.createChooser(intent, getString(R.string.project_feedback_text))); break; } case R.id.drawer_item_report_issue: { Intent intent = new Intent(mContext, MainWebViewActivity.class); intent.putExtra("title", getString(R.string.drawer_item_report_issue)); intent.putExtra("uri", getString(R.string.project_report_issue_uri)); startActivity(intent); break; } } } }); // View pager mViewPager = (ViewPager) findViewById(R.id.main_pager); // Floating action button mFloatingActionButton = (FloatingActionButton) findViewById(R.id.main_fab); mFloatingActionButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { mSearchEditText.requestFocus(); mInputMethodManager.showSoftInput(mSearchEditText, 0); } }); // Alarms Context applicationContext = getApplicationContext(); boolean messageAlarmIsStarted = (PendingIntent.getBroadcast(mContext, 1, new Intent(applicationContext, MessageIntentService.class), PendingIntent.FLAG_NO_CREATE) != null); if (!messageAlarmIsStarted) { MessageAlarm messageAlarm = new MessageAlarm(); messageAlarm.setAlarm(applicationContext); } boolean notificationsFromSlvAlarmIsStarted = (PendingIntent.getBroadcast(mContext, 2, new Intent(applicationContext, NotificationsFromSlvAlarm.class), PendingIntent.FLAG_NO_CREATE) != null); if (!notificationsFromSlvAlarmIsStarted) { NotificationsFromSlvAlarm notificationsFromSlvAlarm = new NotificationsFromSlvAlarm(); notificationsFromSlvAlarm.setAlarm(applicationContext); } // Get data GetDataTask getDataTask = new GetDataTask(); getDataTask.execute(); }
From source file:dentex.youtube.downloader.utils.Utils.java
public static Intent createEmailOnlyChooserIntent(Context ctx, Intent source, CharSequence chooserTitle) { BugSenseHandler.leaveBreadcrumb("createEmailOnlyChooserIntent"); Stack<Intent> intents = new Stack<Intent>(); Intent i = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", "info@domain.com", null)); List<ResolveInfo> activities = ctx.getPackageManager().queryIntentActivities(i, 0); for (ResolveInfo ri : activities) { Intent target = new Intent(source); target.setPackage(ri.activityInfo.packageName); intents.add(target);/*ww w. j a v a 2s . com*/ } if (!intents.isEmpty()) { Intent chooserIntent = Intent.createChooser(intents.remove(0), chooserTitle); chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, intents.toArray(new Parcelable[intents.size()])); return chooserIntent; } else { return Intent.createChooser(source, chooserTitle); } }
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 w w w. j av a 2s .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:de.tum.in.tumcampusapp.fragments.SettingsFragment.java
/** * Handle all clicks on 'button'-preferences * * @param preference Preference that has been clicked * @return True, if handled// ww w . ja v a 2 s. co m */ @Override public boolean onPreferenceClick(Preference preference) { final String key = preference.getKey(); switch (key) { case BUTTON_WIZARD: mContext.finish(); startActivity(new Intent(mContext, WizNavStartActivity.class)); break; case BUTTON_CLEAR_CACHE: // This button invokes the clear cache method new AlertDialog.Builder(mContext).setMessage(R.string.delete_chache_sure) .setPositiveButton(R.string.yes, new Dialog.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { clearCache(); } }).setNegativeButton(R.string.no, null).show(); break; case FACEBOOK: // Open the facebook app or view in a browser when not installed Intent facebook; try { //Try to get facebook package to check if fb app is installed mContext.getPackageManager().getPackageInfo("com.facebook.katana", 0); facebook = new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.facebook_link_app))); } catch (PackageManager.NameNotFoundException e) { //otherwise just open the normal url facebook = new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.facebook_link))); } startActivity(facebook); break; case GITHUB: // Open TCA-github web page startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.github_link)))); break; case FIRST_RUN: // Show first use tutorial SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mContext); SharedPreferences.Editor e = prefs.edit(); e.putBoolean(CardManager.SHOW_TUTORIAL_1, true); e.putBoolean(CardManager.SHOW_TUTORIAL_2, true); e.apply(); CardManager.update(mContext); startActivity(new Intent(mContext, MainActivity.class)); break; case LICENSES: // Show licences new LicensesDialog.Builder(mContext).setNotices(R.raw.notices).setShowFullLicenseText(false) .setIncludeOwnLicense(true).build().show(); break; case FEEDBACK: /* Create the Intent */ Uri uri = Uri.parse("mailto:tca-support.os.in@tum.de?subject=" + getString(R.string.feedbackSubj)); Intent sendIntent = new Intent(Intent.ACTION_SENDTO); sendIntent.setData(uri); /* Send it off to the Activity-Chooser */ startActivity(Intent.createChooser(sendIntent, getString(R.string.send_email))); break; case PRIVACY: Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.url_privacy_policy))); startActivity(myIntent); break; default: return false; } return true; }
From source file:com.android.contacts.activities.ContactSelectionActivity.java
/** * Creates the fragment based on the current request. *//*from w w w . j av a2s . c o m*/ public void configureListFragment() { switch (mActionCode) { case ContactsRequest.ACTION_INSERT_OR_EDIT_CONTACT: { ContactPickerFragment fragment = new ContactPickerFragment(); fragment.setEditMode(true); fragment.setDirectorySearchMode(DirectoryListLoader.SEARCH_MODE_NONE); fragment.setCreateContactEnabled(!mRequest.isSearchMode()); fragment.setListType(ListEvent.ListType.PICK_CONTACT); mListFragment = fragment; break; } case ContactsRequest.ACTION_DEFAULT: case ContactsRequest.ACTION_PICK_CONTACT: { ContactPickerFragment fragment = new ContactPickerFragment(); fragment.setIncludeFavorites(mRequest.shouldIncludeFavorites()); fragment.setListType(ListEvent.ListType.PICK_CONTACT); mListFragment = fragment; break; } case ContactsRequest.ACTION_PICK_OR_CREATE_CONTACT: { ContactPickerFragment fragment = new ContactPickerFragment(); fragment.setCreateContactEnabled(!mRequest.isSearchMode()); fragment.setListType(ListEvent.ListType.PICK_CONTACT); mListFragment = fragment; break; } case ContactsRequest.ACTION_CREATE_SHORTCUT_CONTACT: { ContactPickerFragment fragment = new ContactPickerFragment(); fragment.setShortcutRequested(true); fragment.setListType(ListEvent.ListType.PICK_CONTACT_FOR_SHORTCUT); mListFragment = fragment; break; } case ContactsRequest.ACTION_PICK_PHONE: { PhoneNumberPickerFragment fragment = getPhoneNumberPickerFragment(mRequest); fragment.setListType(ListEvent.ListType.PICK_PHONE); mListFragment = fragment; break; } case ContactsRequest.ACTION_PICK_EMAIL: { mListFragment = new EmailAddressPickerFragment(); mListFragment.setListType(ListEvent.ListType.PICK_EMAIL); break; } case ContactsRequest.ACTION_PICK_PHONES: { mListFragment = new MultiSelectPhoneNumbersListFragment(); mListFragment.setArguments(getIntent().getExtras()); break; } case ContactsRequest.ACTION_PICK_EMAILS: { mListFragment = new MultiSelectEmailAddressesListFragment(); mListFragment.setArguments(getIntent().getExtras()); break; } case ContactsRequest.ACTION_CREATE_SHORTCUT_CALL: { PhoneNumberPickerFragment fragment = getPhoneNumberPickerFragment(mRequest); fragment.setShortcutAction(Intent.ACTION_CALL); fragment.setListType(ListEvent.ListType.PICK_CONTACT_FOR_SHORTCUT); mListFragment = fragment; break; } case ContactsRequest.ACTION_CREATE_SHORTCUT_SMS: { PhoneNumberPickerFragment fragment = getPhoneNumberPickerFragment(mRequest); fragment.setShortcutAction(Intent.ACTION_SENDTO); fragment.setListType(ListEvent.ListType.PICK_CONTACT_FOR_SHORTCUT); mListFragment = fragment; break; } case ContactsRequest.ACTION_PICK_POSTAL: { PostalAddressPickerFragment fragment = new PostalAddressPickerFragment(); fragment.setListType(ListEvent.ListType.PICK_POSTAL); mListFragment = fragment; break; } case ContactsRequest.ACTION_PICK_JOIN: { JoinContactListFragment joinFragment = new JoinContactListFragment(); joinFragment.setTargetContactId(getTargetContactId()); joinFragment.setListType(ListEvent.ListType.PICK_JOIN); mListFragment = joinFragment; break; } case ContactsRequest.ACTION_PICK_GROUP_MEMBERS: { final String accountName = getIntent().getStringExtra(UiIntentActions.GROUP_ACCOUNT_NAME); final String accountType = getIntent().getStringExtra(UiIntentActions.GROUP_ACCOUNT_TYPE); final String accountDataSet = getIntent().getStringExtra(UiIntentActions.GROUP_ACCOUNT_DATA_SET); final ArrayList<String> contactIds = getIntent() .getStringArrayListExtra(UiIntentActions.GROUP_CONTACT_IDS); mListFragment = GroupMemberPickerFragment.newInstance(accountName, accountType, accountDataSet, contactIds); mListFragment.setListType(ListEvent.ListType.PICK_GROUP_MEMBERS); break; } default: throw new IllegalStateException("Invalid action code: " + mActionCode); } // Setting compatibility is no longer needed for PhoneNumberPickerFragment since that logic // has been separated into LegacyPhoneNumberPickerFragment. But we still need to set // compatibility for other fragments. mListFragment.setLegacyCompatibilityMode(mRequest.isLegacyCompatibilityMode()); mListFragment.setDirectoryResultLimit(DEFAULT_DIRECTORY_RESULT_LIMIT); getFragmentManager().beginTransaction().replace(R.id.list_container, mListFragment) .commitAllowingStateLoss(); }
From source file:io.github.sdsstudios.ScoreKeeper.Home.java
@Override public boolean onNavigationItemSelected(MenuItem item) { // Handle navigation view item clicks here. int id = item.getItemId(); switch (id) { case R.id.nav_history: if (gameDBAdapter.open().numRows() > 0) { startActivity(historyIntent); } else {/*from w w w . ja v a 2s . c o m*/ Toast.makeText(this, R.string.no_games, Toast.LENGTH_SHORT).show(); } break; case R.id.nav_players: Toast.makeText(this, R.string.graph_coming_soon, Toast.LENGTH_SHORT).show(); break; case R.id.nav_settings: startActivity(settingsIntent); break; case R.id.nav_about: startActivity(aboutIntent); break; case R.id.nav_rate_review: Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=io.github.sdsstudios.ScoreKeeper")); startActivity(browserIntent); break; case R.id.nav_email_dev: Intent send = new Intent(Intent.ACTION_SENDTO); String uriText = "mailto:" + Uri.encode("seth.d.schroeder@gmail.com") + "?subject=" + Uri.encode("Feedback for Score Keeper app") + "&body=" + Uri.encode(""); Uri uri = Uri.parse(uriText); send.setData(uri); startActivity(Intent.createChooser(send, "Send mail...")); startActivity(send); break; } DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); drawer.closeDrawer(GravityCompat.START); return true; }
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 w w .j ava 2s . 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); } }