Example usage for android.app Activity getString

List of usage examples for android.app Activity getString

Introduction

In this page you can find the example usage for android.app Activity getString.

Prototype

@NonNull
public final String getString(@StringRes int resId) 

Source Link

Document

Returns a localized string from the application's package's default string table.

Usage

From source file:io.github.mkjung.ivi.util.Permissions.java

private static Dialog createDialog(final Activity activity, boolean exit) {
    android.app.AlertDialog.Builder dialogBuilder = new android.app.AlertDialog.Builder(activity)
            .setTitle(activity.getString(R.string.allow_storage_access_title))
            .setMessage(activity.getString(R.string.allow_storage_access_description))
            .setIcon(android.R.drawable.ic_dialog_alert).setPositiveButton(
                    activity.getString(R.string.permission_ask_again), new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int whichButton) {
                            SharedPreferences settings = PreferenceManager
                                    .getDefaultSharedPreferences(activity);
                            if (!settings.getBoolean("user_declined_storage_access", false))
                                requestStoragePermission(activity);
                            else {
                                Intent i = new Intent();
                                i.setAction("android.settings.APPLICATION_DETAILS_SETTINGS");
                                i.addCategory(Intent.CATEGORY_DEFAULT);
                                i.setData(Uri
                                        .parse("package:" + VLCApplication.getAppContext().getPackageName()));
                                i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                                try {
                                    activity.startActivity(i);
                                } catch (Exception ex) {
                                }//from   w  w  w  .  ja  v  a  2  s  .c  o m
                            }
                            SharedPreferences.Editor editor = settings.edit();
                            editor.putBoolean("user_declined_storage_access", true);
                            Util.commitPreferences(editor);
                        }
                    });
    if (exit) {
        dialogBuilder.setNegativeButton(activity.getString(R.string.exit_app),
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        activity.finish();
                    }
                }).setCancelable(false);
    }
    return dialogBuilder.show();
}

From source file:org.videolan.vlc.util.Permissions.java

private static Dialog createDialog(final Activity activity, boolean exit) {
    android.app.AlertDialog.Builder dialogBuilder = new android.app.AlertDialog.Builder(activity)
            .setTitle(activity.getString(R.string.allow_storage_access_title))
            .setMessage(activity.getString(R.string.allow_storage_access_description))
            .setIcon(android.R.drawable.ic_dialog_alert).setPositiveButton(
                    activity.getString(R.string.permission_ask_again), new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int whichButton) {
                            SharedPreferences settings = PreferenceManager
                                    .getDefaultSharedPreferences(activity);
                            if (!settings.getBoolean("user_declined_storage_access", false))
                                requestStoragePermission(activity);
                            else {
                                Intent i = new Intent();
                                i.setAction("android.settings.APPLICATION_DETAILS_SETTINGS");
                                i.addCategory(Intent.CATEGORY_DEFAULT);
                                i.setData(Uri
                                        .parse("package:" + VLCApplication.getAppContext().getPackageName()));
                                i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                                try {
                                    activity.startActivity(i);
                                } catch (Exception ex) {
                                }/*  ww w .ja v  a 2 s. c  o  m*/
                            }
                            SharedPreferences.Editor editor = settings.edit();
                            editor.putBoolean("user_declined_storage_access", true);
                            editor.apply();
                        }
                    });
    if (exit) {
        dialogBuilder.setNegativeButton(activity.getString(R.string.exit_app),
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        activity.finish();
                    }
                }).setCancelable(false);
    }
    return dialogBuilder.show();
}

From source file:com.dalaran.annotation.validator.Validator.java

private static boolean checkFiledToEmail(Activity a, Email length, EditText o) {
    o.setError(null);/*  ww w  . j a v  a2 s.c o m*/
    String s = o.getText().toString();
    boolean matches = pattern.matcher(s).matches();
    if (!matches) {
        o.setError(a.getString(length.value()));
    }

    return matches;
}

From source file:com.yojiokisoft.globish1500.exception.MyUncaughtExceptionHandler.java

/**
 * ??????./*from  w  w  w  .  ja  v a 2 s .  c o m*/
 *
 * @param activity ??Activity?????
 */
public static void sendBugReport(Activity activity) {
    sBugReportFile = new File(MyConst.getUncaughtBugFilePath());
    if (sBugReportFile == null || !sBugReportFile.exists()) {
        return;
    }

    setVersionName();

    MyDialog.Builder.newInstance(activity).setTitle(activity.getString(R.string.err_dialog_title))
            .setMessage(activity.getString(R.string.err_dialog_msg))
            .setPositiveLabel(activity.getString(R.string.send)).setPositiveClickListener(mBugDialogOkClicked)
            .setNegativeLabel(activity.getString(R.string.cancel))
            .setNegativeClickListener(mBugDialogCancelClicked).show();
}

From source file:io.github.carlorodriguez.morningritual.InfoActivity.java

public static void setSectionView(Activity activity, ImageView contentImageView, int drawableId,
        TextView titleTextView, int titleResId, TextView contentTextView, int contentResId) {
    contentImageView.setImageDrawable(ContextCompat.getDrawable(activity, drawableId));

    titleTextView.setText(activity.getString(titleResId));

    contentTextView.setText(activity.getString(contentResId));
}

From source file:com.ashwini.location.notification.LocationUtils.java

public static boolean servicesConnected(Activity activty) {

    // Check that Google Play services is available
    int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(activty);

    // If Google Play services is available
    if (ConnectionResult.SUCCESS == resultCode) {
        // In debug mode, log the status
        Log.d(LocationUtils.APPTAG, activty.getString(R.string.play_services_available));

        // Continue
        return true;
        // Google Play services was not available for some reason
    } else {//from w  w w . j  a  va 2  s. c o m
        // Display an error dialog
        Dialog dialog = GooglePlayServicesUtil.getErrorDialog(resultCode, activty, 0);
        if (dialog != null) {
            ErrorDialogFragment errorFragment = new ErrorDialogFragment();
            errorFragment.setDialog(dialog);
            errorFragment.show(((FragmentActivity) activty).getSupportFragmentManager(), LocationUtils.APPTAG);
        }
        return false;
    }
}

From source file:dentex.youtube.downloader.YTD.java

public static void NoDownProvPopUp(Activity act) {
    PopUps.showPopUp(act.getString(R.string.error), act.getString(R.string.no_downloads_sys_app), "error", act);
}

From source file:com.hemou.android.account.AccountUtils.java

/**
 * Show conflict message about previously registered authenticator from
 * another application/*from  ww  w .  j a v a2 s.c  o m*/
 * 
 * @param activity
 */
private static void showConflictMessage(final Activity activity) {
    AlertDialog dialog = LightAlertDialog.create(activity);
    dialog.setTitle(activity.getString(string.authenticator_conflict_title));
    dialog.setMessage(activity.getString(string.authenticator_conflict_message));
    dialog.setOnCancelListener(new OnCancelListener() {

        @Override
        public void onCancel(DialogInterface dialog) {
            activity.finish();
        }
    });
    dialog.setButton(BUTTON_POSITIVE, activity.getString(android.R.string.ok), new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            activity.finish();
        }
    });
    dialog.show();
}

From source file:org.openmidaas.app.common.Utils.java

private static void setValueAndPersist(Activity activity, GenericAttribute attribute, String value) {
    try {//w w w  .  j  a  va 2s  . c o m
        attribute.setValue(value.toString());
        attribute.save();
        activity.sendBroadcast(new Intent().setAction(Intents.ATTRIBUTE_LIST_CHANGE_EVENT));
    } catch (InvalidAttributeValueException e) {
        DialogUtils.showNeutralButtonDialog(activity, activity.getString(R.string.defaultErrorDialogTitle),
                "Invalid value ");
    } catch (MIDaaSException e) {
        DialogUtils.showNeutralButtonDialog(activity, activity.getString(R.string.defaultErrorDialogTitle),
                e.getError().getErrorMessage());
    }
}

From source file:com.readystatesoftware.ghostlog.MainActivity.java

private static void setupTagFilterPreference(final Activity activity, Preference preference) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
    preference.setSummary(prefs.getString(activity.getString(R.string.pref_tag_filter), null));
    preference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override//from  w w  w . ja v a  2s  .c o m
        public boolean onPreferenceClick(Preference preference) {
            Intent intent = new Intent(activity, TagFilterListActivity.class);
            activity.startActivityForResult(intent, CODE_TAG_FILTER);
            return true;
        }
    });
}