List of usage examples for android.content Intent EXTRA_EMAIL
String EXTRA_EMAIL
To view the source code for android.content Intent EXTRA_EMAIL.
Click Source Link
From source file:com.tortel.deploytrack.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { Intent intent;/* w w w.j a v a 2 s . c o m*/ final String id = mAdapter.getId(mCurrentPosition); switch (item.getItemId()) { case R.id.menu_create_new: intent = new Intent(this, CreateActivity.class); startActivity(intent); return true; case R.id.menu_edit: //If its the info fragment, ignore if (id == null) { return true; } intent = new Intent(this, CreateActivity.class); intent.putExtra("id", id); startActivity(intent); return true; case R.id.menu_delete: //If its the info fragment, ignore if (id == null) { return true; } DeleteDialog dialog = new DeleteDialog(); Bundle args = new Bundle(); args.putString(DeleteDialog.KEY_ID, id); dialog.setArguments(args); dialog.show(getSupportFragmentManager(), "delete"); return true; case R.id.menu_about: Fragment about = new AboutDialog(); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.add(about, "about"); transaction.commit(); return true; case R.id.menu_feedback: intent = new Intent(Intent.ACTION_SEND); intent.putExtra(Intent.EXTRA_EMAIL, new String[] { "Swarner.dev@gmail.com" }); intent.putExtra(Intent.EXTRA_SUBJECT, "Deployment Tracker Feedback"); intent.setType("plain/text"); if (isAvailable(intent)) { startActivity(intent); } return true; case R.id.menu_screenshot: if (!Prefs.isAboutScreenShotShown()) { ScreenShotModeDialog aboutDialog = new ScreenShotModeDialog(); aboutDialog.show(getSupportFragmentManager(), "screenshot"); Prefs.setAboutScreenShotShown(getApplicationContext()); } mScreenShotMode = !mScreenShotMode; Prefs.setScreenShotMode(mScreenShotMode, getApplicationContext()); // Propagate screen shot mode to the widgets Intent updateWidgetIntent = new Intent(WidgetProvider.UPDATE_INTENT); updateWidgetIntent.putExtra(WidgetProvider.KEY_SCREENSHOT_MODE, mScreenShotMode); sendBroadcast(updateWidgetIntent); reload(); return true; case R.id.menu_settings: intent = new Intent(this, SettingsActivity.class); startActivity(intent); return true; } return super.onOptionsItemSelected(item); }
From source file:ru.dublgis.androidhelpers.DesktopUtils.java
public static boolean sendEmail(final Context ctx, final String to, final String subject, final String body, final String attach_file, final boolean force_content_provider, final String authorities) { //Log.d(TAG, "Will send email with subject \"" + // subject + "\" to \"" + to + "\" with attach_file = \"" + attach_file + "\"" + // ", force_content_provider = " + force_content_provider + // ", authorities = \"" + authorities + "\""); try {// ww w.jav a 2 s .c o m // TODO: support multiple recipients String[] recipients = new String[] { to }; final Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", to, null)); List<ResolveInfo> resolveInfos = ctx.getPackageManager().queryIntentActivities(intent, 0); Intent chooserIntent = null; List<Intent> intentList = new ArrayList<Intent>(); Intent i = new Intent(Intent.ACTION_SEND); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); i.setType("message/rfc822"); i.putExtra(Intent.EXTRA_EMAIL, recipients); i.putExtra(Intent.EXTRA_SUBJECT, subject); i.putExtra(Intent.EXTRA_TEXT, body); Uri workaround_grant_permission_for_uri = null; if (attach_file != null && !attach_file.isEmpty()) { if (!force_content_provider && android.os.Build.VERSION.SDK_INT < 23) { i.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(attach_file))); } else { // Android 6+: going the longer route. // For more information, please see: // http://stackoverflow.com/questions/32981194/android-6-cannot-share-files-anymore i.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); workaround_grant_permission_for_uri = FileProvider.getUriForFile(ctx, authorities, new File(attach_file)); i.putExtra(Intent.EXTRA_STREAM, workaround_grant_permission_for_uri); } } for (ResolveInfo resolveInfo : resolveInfos) { String packageName = resolveInfo.activityInfo.packageName; String name = resolveInfo.activityInfo.name; // Some mail clients will not read the URI unless this is done. // See here: https://stackoverflow.com/questions/24467696/android-file-provider-permission-denial if (workaround_grant_permission_for_uri != null) { try { ctx.grantUriPermission(packageName, workaround_grant_permission_for_uri, Intent.FLAG_GRANT_READ_URI_PERMISSION); } catch (final Throwable e) { Log.e(TAG, "grantUriPermission error: ", e); } } Intent fakeIntent = (Intent) i.clone(); fakeIntent.setComponent(new ComponentName(packageName, name)); if (chooserIntent == null) { chooserIntent = fakeIntent; } else { intentList.add(fakeIntent); } } if (chooserIntent == null) { chooserIntent = Intent.createChooser(i, null // "Select email application." ); chooserIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); } else if (!intentList.isEmpty()) { Intent fakeIntent = chooserIntent; chooserIntent = new Intent(Intent.ACTION_CHOOSER); chooserIntent.putExtra(Intent.EXTRA_INTENT, fakeIntent); Intent[] extraIntents = intentList.toArray(new Intent[intentList.size()]); chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, extraIntents); } ctx.startActivity(chooserIntent); return true; } catch (final Throwable e) { Log.e(TAG, "sendEmail exception: ", e); return false; } }
From source file:spit.matrix2017.Fragments.DevelopersFragment.java
@Nullable @Override/*from w w w .ja va 2s .co m*/ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_developers, container, false); email1 = (TextView) view.findViewById(R.id.emailId_tejas); email2 = (TextView) view.findViewById(R.id.emailId_adnan); email3 = (TextView) view.findViewById(R.id.emailId_rohit); email4 = (TextView) view.findViewById(R.id.emailId_mithil); email5 = (TextView) view.findViewById(R.id.emailId_akshay); email6 = (TextView) view.findViewById(R.id.emailId_shubham); g1 = (Button) view.findViewById(R.id.google_tejas); g2 = (Button) view.findViewById(R.id.google_adnan); g3 = (Button) view.findViewById(R.id.google_rohit); g4 = (Button) view.findViewById(R.id.google_mithil); g5 = (Button) view.findViewById(R.id.google_akshay); g6 = (Button) view.findViewById(R.id.google_shubham); l1 = (Button) view.findViewById(R.id.linkedin_tejas); l2 = (Button) view.findViewById(R.id.linkedin_adnan); l3 = (Button) view.findViewById(R.id.linkedin_rohit); l4 = (Button) view.findViewById(R.id.linkedin_mithil); l5 = (Button) view.findViewById(R.id.linkedin_akshay); l6 = (Button) view.findViewById(R.id.linkedin_shubham); image1 = (ImageView) view.findViewById(R.id.pic_tejas); image2 = (ImageView) view.findViewById(R.id.pic_adnan); image3 = (ImageView) view.findViewById(R.id.pic_rohit); image4 = (ImageView) view.findViewById(R.id.pic_mithil); image5 = (ImageView) view.findViewById(R.id.pic_akshay); image6 = (ImageView) view.findViewById(R.id.pic_shubham); /*Add Your Pics Here And Not In Xml*/ Picasso.with(getActivity()).load(R.drawable.dev_tejas_bhitle).into(image1); Picasso.with(getActivity()).load(R.drawable.dev_adnan_ansari).into(image2); Picasso.with(getActivity()).load(R.drawable.dev_rohit_nahata).into(image3); Picasso.with(getActivity()).load(R.drawable.dev_mithil_gotarne).into(image4); Picasso.with(getActivity()).load(R.drawable.dev_akshay_shah).into(image5); Picasso.with(getActivity()).load(R.drawable.dev_shubham_mahajan).into(image6); View.OnClickListener linkListener = new View.OnClickListener() { @Override public void onClick(View v) { Uri uri; switch (v.getId()) { /*Google+ links*/ case R.id.google_tejas: uri = Uri.parse(getResources().getString(R.string.googleplus_tejas)); break; case R.id.google_adnan: uri = Uri.parse(getResources().getString(R.string.googleplus_adnan)); break; case R.id.google_rohit: uri = Uri.parse(getResources().getString(R.string.googleplus_rohit)); break; case R.id.google_mithil: uri = Uri.parse(getResources().getString(R.string.googleplus_mithil)); break; case R.id.google_akshay: uri = Uri.parse(getResources().getString(R.string.googleplus_akshay)); break; case R.id.google_shubham: uri = Uri.parse(getResources().getString(R.string.googleplus_shubham)); break; /*LInkedin Links*/ case R.id.linkedin_tejas: uri = Uri.parse(getResources().getString(R.string.linkedin_tejas)); break; case R.id.linkedin_adnan: uri = Uri.parse(getResources().getString(R.string.linkedin_adnan)); break; case R.id.linkedin_rohit: uri = Uri.parse(getResources().getString(R.string.linkedin_rohit)); break; case R.id.linkedin_mithil: uri = Uri.parse(getResources().getString(R.string.linkedin_mithil)); break; case R.id.linkedin_akshay: uri = Uri.parse(getResources().getString(R.string.linkedin_akshay)); break; case R.id.linkedin_shubham: uri = Uri.parse(getResources().getString(R.string.linkedin_shubham)); break; default: uri = Uri.parse(getResources().getString(R.string.linkedin_tejas)); } Intent i = new Intent(Intent.ACTION_VIEW, uri); try { startActivity(i); } catch (Exception e) { Toast.makeText(getActivity(), "Error Loading Link", Toast.LENGTH_SHORT).show(); } } }; View.OnClickListener emailListener = new View.OnClickListener() { @Override public void onClick(View v) { String to = ""; switch (v.getId()) { /*Email Ids*/ case R.id.emailId_tejas: to = getResources().getString(R.string.email_tejas); break; case R.id.emailId_adnan: to = getResources().getString(R.string.email_adnan); break; case R.id.emailId_rohit: to = getResources().getString(R.string.email_rohit); break; case R.id.emailId_mithil: to = getResources().getString(R.string.email_mithil); break; case R.id.emailId_akshay: to = getResources().getString(R.string.email_akshay); break; case R.id.emailId_shubham: to = getResources().getString(R.string.email_shubham); break; } Intent intent = new Intent(); intent.setAction(Intent.ACTION_SENDTO); intent.setType("text/plain"); intent.setData(Uri.parse("mailto:" + to)); intent.putExtra(Intent.EXTRA_EMAIL, to); try { startActivity(Intent.createChooser(intent, "Send Email")); } catch (Exception e) { Toast.makeText(getActivity(), e.getStackTrace().toString(), Toast.LENGTH_SHORT).show(); } } }; email1.setOnClickListener(emailListener); email2.setOnClickListener(emailListener); email3.setOnClickListener(emailListener); email4.setOnClickListener(emailListener); email5.setOnClickListener(emailListener); email6.setOnClickListener(emailListener); g1.setOnClickListener(linkListener); g2.setOnClickListener(linkListener); g3.setOnClickListener(linkListener); g4.setOnClickListener(linkListener); g5.setOnClickListener(linkListener); g6.setOnClickListener(linkListener); l1.setOnClickListener(linkListener); l2.setOnClickListener(linkListener); l3.setOnClickListener(linkListener); l4.setOnClickListener(linkListener); l5.setOnClickListener(linkListener); l6.setOnClickListener(linkListener); return view; }
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 v a 2 s . c o m Toast.makeText(this, "Please Give your feedback ", Toast.LENGTH_SHORT).show(); } }
From source file:de.domjos.schooltools.helper.Helper.java
public static void sendMailWithAttachment(String email, String subject, File file, Context context) { Uri attachment = FileProvider.getUriForFile(context, context.getPackageName() + ".my.package.name.provider", file);/*from w w w. ja va 2 s . c om*/ Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("vnd.android.cursor.dir/email"); String[] to = { email }; intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.putExtra(Intent.EXTRA_EMAIL, to); intent.putExtra(Intent.EXTRA_STREAM, attachment); intent.putExtra(Intent.EXTRA_SUBJECT, subject); context.startActivity(Intent.createChooser(intent, "Send email...")); }
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 * //from w w w .jav a 2s . c om */ 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.mech.tech.meet.activities.scenario.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(); //noinspection SimplifiableIfStatement if (id == R.id.action_facebook) { String url = "http://www.facebook.com/mtmuec"; Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(url));/*from w ww . j av a2 s. c om*/ startActivity(i); return true; } if (id == R.id.action_twitter) { String url = "http://www.twitter.com/mechtechmeet"; Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(url)); startActivity(i); return true; } if (id == R.id.action_licences) { Intent i = new Intent(this, LicenseActivity.class); startActivity(i); return true; } if (id == R.id.action_query) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("message/rfc822"); intent.putExtra(Intent.EXTRA_EMAIL, new String[] { "mechtechmeet@gmail.com" }); intent.putExtra(Intent.EXTRA_SUBJECT, "subject"); intent.putExtra(Intent.EXTRA_TEXT, "message"); Intent mailer = Intent.createChooser(intent, null); startActivity(mailer); return true; } return super.onOptionsItemSelected(item); }
From source file:eu.masconsult.bgbanking.activity.HomeActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); MenuItem refreshItem = menu.add(R.string.menu_item_refresh); refreshItem.setIcon(R.drawable.ic_menu_refresh); refreshItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW); refreshItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override//from ww w . ja va 2s .com public boolean onMenuItemClick(MenuItem item) { AccountManager accountManager = AccountManager.get(HomeActivity.this); if (accountManager == null) { return false; } long cnt = 0; Bank[] banks = Bank.values(); for (Bank bank : banks) { for (Account account : accountManager .getAccountsByType(bank.getAccountType(HomeActivity.this))) { Log.v(TAG, String.format("account: %s, %s, %s", account.name, account.type, ContentResolver.getIsSyncable(account, BankingContract.AUTHORITY))); Bundle bundle = new Bundle(); bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true); ContentResolver.requestSync(account, BankingContract.AUTHORITY, bundle); cnt++; } } EasyTracker.getTracker().trackEvent("ui_action", "menu_item_click", "refresh", cnt); return true; } }); MenuItem addAccountItem = menu.add(R.string.menu_item_add_account); addAccountItem.setIcon(R.drawable.ic_menu_add); addAccountItem .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW); addAccountItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { addAccount(); EasyTracker.getTracker().trackEvent("ui_action", "menu_item_click", "add_account", 1l); return true; } }); MenuItem sendFeedback = menu.add(R.string.menu_item_send_feedback); sendFeedback.setIcon(R.drawable.ic_menu_start_conversation); sendFeedback.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); sendFeedback.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { PackageInfo manager; try { manager = getPackageManager().getPackageInfo(getPackageName(), 0); } catch (NameNotFoundException e) { manager = new PackageInfo(); manager.versionCode = 0; manager.versionName = "undef"; } try { startActivity(new Intent(Intent.ACTION_SEND).setType("plain/text") .putExtra(Intent.EXTRA_EMAIL, new String[] { "bgbanks@masconsult.eu" }) .putExtra(Intent.EXTRA_SUBJECT, "BG Banks v" + manager.versionName + "-" + manager.versionCode + " feedback")); EasyTracker.getTracker().trackEvent("ui_action", "menu_item_click", "send_feedback", 1l); } catch (ActivityNotFoundException e) { Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_SHORT).show(); } return true; } }); return true; }
From source file:de.schildbach.wallet.ui.ReportIssueDialogBuilder.java
private void startSend(final CharSequence subject, final CharSequence text, final ArrayList<Uri> attachments) { final Intent intent; if (attachments.size() == 0) { intent = new Intent(Intent.ACTION_SEND); intent.setType("message/rfc822"); } else if (attachments.size() == 1) { intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_STREAM, attachments.get(0)); } else {//from w w w .j a va2 s . com intent = new Intent(Intent.ACTION_SEND_MULTIPLE); intent.setType("text/plain"); intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, attachments); } intent.putExtra(Intent.EXTRA_EMAIL, new String[] { Constants.REPORT_EMAIL }); if (subject != null) intent.putExtra(Intent.EXTRA_SUBJECT, subject); intent.putExtra(Intent.EXTRA_TEXT, text); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); try { context.startActivity(Intent.createChooser(intent, context.getString(R.string.report_issue_dialog_mail_intent_chooser))); log.info("invoked chooser for sending issue report"); } catch (final Exception x) { Toast.makeText(context, R.string.report_issue_dialog_mail_intent_failed, Toast.LENGTH_LONG).show(); log.error("report issue failed", x); } }
From source file:com.todoroo.astrid.sync.SyncProviderPreferences.java
/** * * @param resource//from ww w .ja v a 2s.c om * if null, updates all resources */ @Override public void updatePreferences(Preference preference, Object value) { final Resources r = getResources(); // interval if (r.getString(getUtilities().getSyncIntervalKey()).equals(preference.getKey())) { int index = AndroidUtilities.indexOf(r.getStringArray(R.array.sync_SPr_interval_values), (String) value); if (index <= 0) preference.setSummary(R.string.sync_SPr_interval_desc_disabled); else preference.setSummary(r.getString(R.string.sync_SPr_interval_desc, r.getStringArray(R.array.sync_SPr_interval_entries)[index])); } // status else if (r.getString(R.string.sync_SPr_status_key).equals(preference.getKey())) { boolean loggedIn = getUtilities().isLoggedIn(); String status; //String subtitle = ""; //$NON-NLS-1$ // ! logged in - display message, click -> sync if (!loggedIn) { status = r.getString(R.string.sync_status_loggedout); statusColor = Color.rgb(19, 132, 165); } // sync is occurring else if (getUtilities().isOngoing()) { status = r.getString(R.string.sync_status_ongoing); statusColor = Color.rgb(0, 0, 100); } // last sync had errors else if (getUtilities().getLastError() != null || getUtilities().getLastAttemptedSyncDate() != 0) { // last sync was failure if (getUtilities().getLastAttemptedSyncDate() != 0) { status = r.getString(R.string.sync_status_failed, DateUtilities.getDateStringWithTime( SyncProviderPreferences.this, new Date(getUtilities().getLastAttemptedSyncDate()))); statusColor = Color.rgb(100, 0, 0); if (getUtilities().getLastSyncDate() > 0) { // subtitle = r.getString(R.string.sync_status_failed_subtitle, // DateUtilities.getDateStringWithTime(SyncProviderPreferences.this, // new Date(getUtilities().getLastSyncDate()))); } } else { long lastSyncDate = getUtilities().getLastSyncDate(); String dateString = lastSyncDate > 0 ? DateUtilities.getDateStringWithTime(SyncProviderPreferences.this, new Date(lastSyncDate)) : ""; //$NON-NLS-1$ status = r.getString(R.string.sync_status_errors, dateString); statusColor = Color.rgb(100, 100, 0); } } else if (getUtilities().getLastSyncDate() > 0) { status = r.getString(R.string.sync_status_success, DateUtilities.getDateStringWithTime( SyncProviderPreferences.this, new Date(getUtilities().getLastSyncDate()))); statusColor = Color.rgb(0, 100, 0); } else { status = r.getString(R.string.sync_status_never); statusColor = Color.rgb(0, 0, 100); } preference.setTitle(R.string.sync_SPr_sync); preference.setSummary(r.getString(R.string.sync_SPr_status_subtitle, status)); preference.setOnPreferenceClickListener(new OnPreferenceClickListener() { public boolean onPreferenceClick(Preference p) { startSync(); return true; } }); View view = findViewById(R.id.status); if (view != null) view.setBackgroundColor(statusColor); } else if (r.getString(R.string.sync_SPr_key_last_error).equals(preference.getKey())) { if (getUtilities().getLastError() != null) { // Display error final String service = getTitle().toString(); final String lastErrorFull = getUtilities().getLastError(); final String lastErrorDisplay = adjustErrorForDisplay(r, lastErrorFull, service); preference.setTitle(R.string.sync_SPr_last_error); preference.setSummary(R.string.sync_SPr_last_error_subtitle); preference.setOnPreferenceClickListener(new OnPreferenceClickListener() { @Override @SuppressWarnings("nls") public boolean onPreferenceClick(Preference pref) { // Show last error new AlertDialog.Builder(SyncProviderPreferences.this).setTitle(R.string.sync_SPr_last_error) .setMessage(lastErrorDisplay) .setPositiveButton(R.string.sync_SPr_send_report, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Intent emailIntent = new Intent(Intent.ACTION_SEND); emailIntent.setType("plain/text") .putExtra(Intent.EXTRA_EMAIL, new String[] { "android-bugs@astrid.com" }) .putExtra(Intent.EXTRA_SUBJECT, service + " Sync Error") .putExtra(Intent.EXTRA_TEXT, lastErrorFull); startActivity(Intent.createChooser(emailIntent, r.getString(R.string.sync_SPr_send_report))); } }).setNegativeButton(R.string.DLG_close, null).create().show(); return true; } }); } else { PreferenceCategory statusCategory = (PreferenceCategory) findPreference( r.getString(R.string.sync_SPr_group_status)); statusCategory.removePreference(findPreference(r.getString(R.string.sync_SPr_key_last_error))); } } // log out button else if (r.getString(R.string.sync_SPr_forget_key).equals(preference.getKey())) { boolean loggedIn = getUtilities().isLoggedIn(); preference.setOnPreferenceClickListener(new OnPreferenceClickListener() { public boolean onPreferenceClick(Preference p) { DialogUtilities.okCancelDialog(SyncProviderPreferences.this, r.getString(R.string.sync_forget_confirm), new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { logOut(); initializePreference(getPreferenceScreen()); } }, null); return true; } }); if (!loggedIn) { PreferenceCategory category = (PreferenceCategory) findPreference( r.getString(R.string.sync_SPr_key_options)); category.removePreference(preference); } } }