List of usage examples for android.content Intent createChooser
public static Intent createChooser(Intent target, CharSequence title)
From source file:com.atahani.telepathy.ui.fragment.AboutDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); LayoutInflater inflater = getActivity().getLayoutInflater(); View customLayout = inflater.inflate(R.layout.fragment_about_dialog, null); //config app version information mAppPreferenceTools = new AppPreferenceTools(TApplication.applicationContext); AppCompatTextView txAndroidAppVerInfo = (AppCompatTextView) customLayout .findViewById(R.id.tx_android_ver_info); txAndroidAppVerInfo.setText(String.format(getString(R.string.label_telepathy_for_android), mAppPreferenceTools.getTheLastAppVersion())); txAndroidAppVerInfo.setOnClickListener(new View.OnClickListener() { @Override// w w w.ja va 2 s . com public void onClick(View v) { try { //open browser to navigate telepathy website Uri telepathyWebSiteUri = Uri.parse("https://github.com/atahani/telepathy-android.git"); startActivity(new Intent(Intent.ACTION_VIEW, telepathyWebSiteUri)); ((TelepathyBaseActivity) getActivity()).setAnimationOnStart(); } catch (Exception ex) { AndroidUtilities.processApplicationError(ex, true); if (isAdded() && getActivity() != null) { Snackbar.make(getActivity().findViewById(android.R.id.content), getString(R.string.re_action_internal_app_error), Snackbar.LENGTH_LONG).show(); } } } }); //config google play store link AppCompatTextView txRateUsOnGooglePlayStore = (AppCompatTextView) customLayout .findViewById(R.id.tx_rate_us_on_play_store); txRateUsOnGooglePlayStore.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //navigate to market for rate application Uri uri = Uri.parse("market://details?id=" + TApplication.applicationContext.getPackageName()); Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri); // To count with Play market backstack, After pressing back button, // to taken back to our application, we need to add following flags to intent. goToMarket.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_MULTIPLE_TASK); try { startActivity(goToMarket); ((TelepathyBaseActivity) getActivity()).setAnimationOnStart(); } catch (ActivityNotFoundException e) { startActivity( new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=" + TApplication.applicationContext.getPackageName()))); } } }); //config twitter link AppCompatTextView txTwitterLink = (AppCompatTextView) customLayout.findViewById(R.id.tx_twitter_telepathy); txTwitterLink.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { try { // If Twitter app is not installed, start browser. Uri twitterUri = Uri.parse("http://twitter.com/"); startActivity(new Intent(Intent.ACTION_VIEW, twitterUri)); ((TelepathyBaseActivity) getActivity()).setAnimationOnStart(); } catch (Exception ex) { AndroidUtilities.processApplicationError(ex, true); if (isAdded() && getActivity() != null) { Snackbar.make(getActivity().findViewById(android.R.id.content), getString(R.string.re_action_internal_app_error), Snackbar.LENGTH_LONG).show(); } } } }); //config privacy link AppCompatTextView txPrivacyLink = (AppCompatTextView) customLayout.findViewById(R.id.tx_privacy); txPrivacyLink.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { try { //open browser to navigate privacy link Uri privacyPolicyUri = Uri .parse("https://github.com/atahani/telepathy-android/blob/master/LICENSE.md"); startActivity(new Intent(Intent.ACTION_VIEW, privacyPolicyUri)); ((TelepathyBaseActivity) getActivity()).setAnimationOnStart(); } catch (Exception ex) { AndroidUtilities.processApplicationError(ex, true); if (isAdded() && getActivity() != null) { Snackbar.make(getActivity().findViewById(android.R.id.content), getString(R.string.re_action_internal_app_error), Snackbar.LENGTH_LONG).show(); } } } }); //config report bug to open mail application and send bugs report AppCompatTextView txReportBug = (AppCompatTextView) customLayout.findViewById(R.id.tx_report_bug); txReportBug.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { try { final Intent emailIntent = new Intent(Intent.ACTION_SENDTO); emailIntent.setType("plain/text"); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, getString(R.string.label_report_bug_email_subject)); emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, emailDeviceInformation()); emailIntent.setData(Uri.parse("mailto:" + getString(R.string.telepathy_report_bug_email))); startActivity(Intent.createChooser(emailIntent, getString(R.string.label_report_bug_choose_mail_app))); ((TelepathyBaseActivity) getActivity()).setAnimationOnStart(); } catch (Exception ex) { AndroidUtilities.processApplicationError(ex, true); if (isAdded() && getActivity() != null) { Snackbar.make(getActivity().findViewById(android.R.id.content), getString(R.string.re_action_internal_app_error), Snackbar.LENGTH_LONG).show(); } } } }); //config the about footer image view AboutFooterImageView footerImageView = (AboutFooterImageView) customLayout .findViewById(R.id.im_delete_user_account); footerImageView.setTouchOnImageViewEventListener(new AboutFooterImageView.touchOnImageViewEventListener() { @Override public void onDoubleTab() { try { //confirm account delete via alert dialog final AlertDialog.Builder confirmAccountDeleteDialog = new AlertDialog.Builder(getActivity()); confirmAccountDeleteDialog.setTitle(getString(R.string.label_delete_user_account)); confirmAccountDeleteDialog .setMessage(getString(R.string.label_delete_user_account_description)); confirmAccountDeleteDialog.setNegativeButton(getString(R.string.action_no), null); confirmAccountDeleteDialog.setPositiveButton(getString(R.string.action_yes), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { //ok to delete account action final ProgressDialog progressDialog = new ProgressDialog(getActivity()); progressDialog.setCancelable(false); progressDialog.setCanceledOnTouchOutside(false); progressDialog .setMessage(getString(R.string.re_action_on_deleting_user_account)); progressDialog.show(); TService tService = ((TelepathyBaseActivity) getActivity()).getTService(); tService.deleteUserAccount(new Callback<TOperationResultModel>() { @Override public void success(TOperationResultModel tOperationResultModel, Response response) { if (getActivity() != null && isAdded()) { //broad cast to close all of the realm instance Intent intentToCloseRealm = new Intent( Constants.TELEPATHY_BASE_ACTIVITY_INTENT_FILTER); intentToCloseRealm.putExtra(Constants.ACTION_TO_DO_PARAM, Constants.CLOSE_REALM_DB); LocalBroadcastManager.getInstance(getActivity()) .sendBroadcastSync(intentToCloseRealm); mAppPreferenceTools.removeAllOfThePref(); // for sign out google first build GoogleAPIClient final GoogleApiClient googleApiClient = new GoogleApiClient.Builder( TApplication.applicationContext) .addApi(Auth.GOOGLE_SIGN_IN_API).build(); googleApiClient.connect(); googleApiClient.registerConnectionCallbacks( new GoogleApiClient.ConnectionCallbacks() { @Override public void onConnected(Bundle bundle) { Auth.GoogleSignInApi.signOut(googleApiClient) .setResultCallback( new ResultCallback<Status>() { @Override public void onResult( Status status) { //also revoke google access Auth.GoogleSignInApi .revokeAccess( googleApiClient) .setResultCallback( new ResultCallback<Status>() { @Override public void onResult( Status status) { progressDialog .dismiss(); TelepathyBaseActivity currentActivity = (TelepathyBaseActivity) TApplication.mCurrentActivityInApplication; if (currentActivity != null) { Intent intent = new Intent( TApplication.applicationContext, SignInActivity.class); intent.setFlags( Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); currentActivity .startActivity( intent); currentActivity .setAnimationOnStart(); currentActivity .finish(); } } }); } }); } @Override public void onConnectionSuspended(int i) { //do nothing } }); } } @Override public void failure(RetrofitError error) { progressDialog.dismiss(); if (getActivity() != null && isAdded()) { CommonFeedBack commonFeedBack = new CommonFeedBack( getActivity().findViewById(android.R.id.content), getActivity()); commonFeedBack.checkCommonErrorAndBackUnCommonOne(error); } } }); } }); confirmAccountDeleteDialog.show(); } catch (Exception ex) { AndroidUtilities.processApplicationError(ex, true); if (isAdded() && getActivity() != null) { Snackbar.make(getActivity().findViewById(android.R.id.content), getString(R.string.re_action_internal_app_error), Snackbar.LENGTH_LONG).show(); } } } }); builder.setView(customLayout); return builder.create(); }
From source file:com.christophergs.mbientbasic.SensorFragment.java
@Override public void onViewCreated(final View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); if (sensorResId != 2131165359) { chart = (LineChart) view.findViewById(R.id.data_chart); initializeChart();/*from w w w. ja va 2 s. c om*/ resetData(false); chart.invalidate(); chart.setDescription(null); Button clearButton = (Button) view.findViewById(R.id.layout_two_button_left); clearButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { refreshChart(true); } }); clearButton.setText(R.string.label_clear); } else { Log.i(TAG, "Pie Chart"); } ((Switch) view.findViewById(R.id.sample_control)) .setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { if (b) { moveViewToLast(); setup(); chartHandler.postDelayed(updateChartTask, UPDATE_PERIOD); } else { chart.setVisibleXRangeMaximum(sampleCount); clean(); if (streamRouteManager != null) { streamRouteManager.remove(); streamRouteManager = null; } chartHandler.removeCallbacks(updateChartTask); } } }); Button chartButton = (Button) view.findViewById(R.id.layout_two_button_center); chartButton.setText(R.string.label_pie); Button saveButton = (Button) view.findViewById(R.id.layout_two_button_right); saveButton.setText(R.string.label_save); saveButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { String filename = saveData(false); if (filename != null) { File dataFile = getActivity().getFileStreamPath(filename); Uri contentUri = FileProvider.getUriForFile(getActivity(), "com.mbientlab.metawear.app.fileprovider2", dataFile); Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_SUBJECT, filename); intent.putExtra(Intent.EXTRA_STREAM, contentUri); startActivity(Intent.createChooser(intent, "Saving Data")); } } }); }
From source file:com.cybrosys.palmcalc.PalmCalcActivity.java
private void feedbackmail() { String to = "android@cybrosys.com"; String subject = "PalmCalc FeedBack"; String message = etxtFeedback.getText().toString(); if (message.length() != 0) { Intent email = new Intent(Intent.ACTION_SEND); email.putExtra(Intent.EXTRA_EMAIL, new String[] { to }); email.putExtra(Intent.EXTRA_SUBJECT, subject); email.putExtra(Intent.EXTRA_TEXT, message); email.setType("message/rfc822"); startActivity(Intent.createChooser(email, "Choose an Email client :")); Toast.makeText(this, "Thank you for your Valuable feedback....", Toast.LENGTH_SHORT).show(); } else {//from w w w . j a va 2s.c om Toast.makeText(this, "Please Give your feedback ", Toast.LENGTH_SHORT).show(); } }
From source file:at.wada811.dayscounter.CrashExceptionHandler.java
public static void reportProblem(Context context) { File file = ResourceUtils.getFile(context, CrashExceptionHandler.FILE_NAME); File dirFile = new File(Environment.getExternalStorageDirectory(), context.getString(R.string.app_dir)); File attachmentFile = new File(dirFile, CrashExceptionHandler.FILE_NAME); Intent intent;//from w w w.j a v a2 s . c o m String report = ResourceUtils.readFileString(context, CrashExceptionHandler.FILE_NAME); if (FileUtils.move(file, attachmentFile)) { intent = IntentUtils.createSendMailIntent(CrashExceptionHandler.MAILTO, context.getString(R.string.reportProblemMailTitle), context.getString(R.string.reportProblemMailBody)); intent = IntentUtils.addFile(intent, attachmentFile); } else { intent = IntentUtils.createSendMailIntent(CrashExceptionHandler.MAILTO, context.getString(R.string.reportProblemMailTitle), context.getString(R.string.reportProblemMailBody, report)); } Intent gmailIntent = IntentUtils.createGmailIntent(intent); if (IntentUtils.canIntent(context, gmailIntent)) { ((Activity) context).startActivityForResult(gmailIntent, REQ_REPORT); } else if (IntentUtils.canIntent(context, intent)) { ((Activity) context).startActivityForResult( Intent.createChooser(intent, context.getString(R.string.reportProblem)), REQ_REPORT); } else { ToastUtils.show(context, R.string.mailerNotFound); } }
From source file:es.uja.photofirma.android.LoginActivity.java
/** * Accin ejecutada si el usuario pulsa sobre la opcin que indica que no recuerda su contrasea, * abre una instancia de la aplicacin de email del dispositivo para contactar con el administrador * /*w w w . j a v a 2 s. c o m*/ */ public void onForgotPassword(View view) { Intent it = new Intent(Intent.ACTION_SEND); it.putExtra(Intent.EXTRA_EMAIL, new String[] { getString(R.string.developer_email) }); it.putExtra(Intent.EXTRA_SUBJECT, "Olvid mi contrasea..."); it.setType("message/rfc822"); startActivity(Intent.createChooser(it, null)); }
From source file:com.dwdesign.tweetings.fragment.BaseUsersListFragment.java
@Override public boolean onMenuItemClick(final MenuItem item) { if (mSelectedUser == null) return false; switch (item.getItemId()) { case MENU_VIEW_PROFILE: { openUserProfile(mSelectedUser.user_id, mSelectedUser.screen_name); break;// www . ja va 2 s .c o m } case MENU_EXTENSIONS: { final Intent intent = new Intent(INTENT_ACTION_EXTENSION_OPEN_USER); final Bundle extras = new Bundle(); extras.putParcelable(INTENT_KEY_USER, mSelectedUser); intent.putExtras(extras); startActivity(Intent.createChooser(intent, getString(R.string.open_with_extensions))); break; } case MENU_MULTI_SELECT: { if (!mApplication.isMultiSelectActive()) { mApplication.startMultiSelect(); } final NoDuplicatesLinkedList<Object> list = mApplication.getSelectedItems(); if (!list.contains(mSelectedUser)) { list.add(mSelectedUser); } break; } } return true; }
From source file:com.google.cloud.solutions.smashpix.MainActivity.java
/** * Gets a picture from the built in image gallery. *//* w w w.j a v a 2 s . co m*/ public void getPicture() { Intent intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); intent.setType(INTENT_IMAGE_PICK_FILTER); startActivityForResult(Intent.createChooser(intent, getResources().getString(R.string.select_image)), Constants.SELECT_PICTURE); }
From source file:com.code.android.vibevault.FeaturedShowsScreen.java
/** Handle user's long-click selection. * *//* ww w. j a v a2 s . com*/ @Override public boolean onContextItemSelected(MenuItem item) { AdapterContextMenuInfo menuInfo = (AdapterContextMenuInfo) item.getMenuInfo(); if (menuInfo != null) { ArchiveShowObj selShow = (ArchiveShowObj) featuredShowsList.getAdapter().getItem(menuInfo.position); switch (item.getItemId()) { case VibeVault.EMAIL_LINK: final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType("plain/text"); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Great show on archive.org: " + selShow.getArtistAndTitle()); emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Hey,\n\nYou should listen to " + selShow.getArtistAndTitle() + ". You can find it here: " + selShow.getShowURL() + "\n\nSent using VibeVault for Android."); startActivity(Intent.createChooser(emailIntent, "Send mail...")); return true; case (VibeVault.ADD_TO_FAVORITE_LIST): VibeVault.db.insertFavoriteShow(selShow); return true; default: break; } return false; } return true; }
From source file:ca.rmen.android.scrumchatter.main.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.action_team_switch: mTeams.selectTeam(mTeam);// w w w. j a v a 2 s . c o m return true; case R.id.action_team_rename: mTeams.renameTeam(mTeam); return true; case R.id.action_team_delete: mTeams.deleteTeam(mTeam); return true; case R.id.action_import: Intent importIntent = new Intent(Intent.ACTION_GET_CONTENT); importIntent.setType("file/*"); startActivityForResult( Intent.createChooser(importIntent, getResources().getText(R.string.action_import)), ACTIVITY_REQUEST_CODE_IMPORT); return true; case R.id.action_share: // Build a chooser dialog for the file format. ScrumChatterDialog.showChoiceDialog(this, R.string.export_choice_title, R.array.export_choices, -1, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String[] exportChoices = getResources().getStringArray(R.array.export_choices); FileExport fileExport = null; if (getString(R.string.export_format_excel).equals(exportChoices[which])) fileExport = new MeetingsExport(MainActivity.this); else if (getString(R.string.export_format_db).equals(exportChoices[which])) fileExport = new DBExport(MainActivity.this); shareFile(fileExport); } }); return true; case R.id.action_about: Intent intent = new Intent(this, AboutActivity.class); startActivity(intent); return true; } return super.onOptionsItemSelected(item); }
From source file:com.ap.jesus.migsv2.CamActivity.java
protected void saveScreenCaptureToExternalStorage(Bitmap screenCapture) { if (screenCapture != null) { // store screenCapture into external cache directory final File screenCaptureFile = new File(Environment.getExternalStorageDirectory().toString(), "screenCapture_" + System.currentTimeMillis() + ".jpg"); // 1. Save bitmap to file & compress to jpeg. You may use PNG too try {// w w w .j a v a 2s . com final FileOutputStream out = new FileOutputStream(screenCaptureFile); screenCapture.compress(Bitmap.CompressFormat.JPEG, 90, out); out.flush(); out.close(); // 2. create send intent final Intent share = new Intent(Intent.ACTION_SEND); share.setType("image/jpg"); share.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(screenCaptureFile)); // 3. launch intent-chooser final String chooserTitle = "Share Snaphot"; CamActivity.this.startActivity(Intent.createChooser(share, chooserTitle)); } catch (final Exception e) { // should not occur when all permissions are set CamActivity.this.runOnUiThread(new Runnable() { @Override public void run() { // show toast message in case something went wrong Toast.makeText(CamActivity.this, "Unexpected error, " + e, Toast.LENGTH_LONG).show(); } }); } } }