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:de.baumann.browser.helper.helper_main.java

public static void grantPermissionsLoc(final Activity from) {

    final SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(from);

    if (android.os.Build.VERSION.SDK_INT >= 23) {

        if (sharedPref.getBoolean("perm_notShow", false)) {
            int hasACCESS_FINE_LOCATION = from.checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION);
            if (hasACCESS_FINE_LOCATION != PackageManager.PERMISSION_GRANTED) {
                if (!from.shouldShowRequestPermissionRationale(Manifest.permission.ACCESS_FINE_LOCATION)) {
                    new AlertDialog.Builder(from).setTitle(R.string.app_permissions_title)
                            .setMessage(helper_main.textSpannable(from.getString(R.string.app_permissions)))
                            .setNeutralButton(R.string.toast_notAgain, new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int which) {
                                    dialog.cancel();
                                    sharedPref.edit().putBoolean("perm_notShow", false).apply();
                                }//from  ww w . ja v  a 2  s .  c om
                            }).setPositiveButton(from.getString(R.string.toast_yes),
                                    new DialogInterface.OnClickListener() {
                                        @Override
                                        public void onClick(DialogInterface dialog, int which) {
                                            if (android.os.Build.VERSION.SDK_INT >= 23)
                                                from.requestPermissions(
                                                        new String[] {
                                                                Manifest.permission.ACCESS_FINE_LOCATION },
                                                        REQUEST_CODE_ASK_PERMISSIONS_1);
                                        }
                                    })
                            .setNegativeButton(from.getString(R.string.toast_cancel), null).show();
                    return;
                }
                from.requestPermissions(new String[] { Manifest.permission.ACCESS_FINE_LOCATION },
                        REQUEST_CODE_ASK_PERMISSIONS_1);
            }
        }
    }
}

From source file:com.google.firebase.linelogindemo.util.LineLoginHelper.java

public LineLoginHelper(Activity activity) {
    mActivity = activity;//w  w  w .  j  av a  2 s  . c o m
    mLineAcessscodeVerificationEndpoint = activity.getString(R.string.validation_server_domain)
            + "/verifyToken";
}

From source file:com.jetheis.android.makeitrain.fragment.DenominationDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Activity activity = getActivity();

    final CharSequence[] items;

    if (mVipMode) {
        items = new CharSequence[] { activity.getString(R.string.denomination_1),
                activity.getString(R.string.denomination_5), activity.getString(R.string.denomination_10),
                activity.getString(R.string.denomination_20), activity.getString(R.string.denomination_50),
                activity.getString(R.string.denomination_100) };
    } else if (mVipModeUnavailable) {
        items = new CharSequence[] { activity.getString(R.string.denomination_1),
                activity.getString(R.string.denomination_5), activity.getString(R.string.denomination_10),
                activity.getString(R.string.denomination_20) };
    } else {/*from w ww.j  a  v  a 2  s.  c  om*/
        items = new CharSequence[] { activity.getString(R.string.denomination_1),
                activity.getString(R.string.denomination_5), activity.getString(R.string.denomination_10),
                activity.getString(R.string.denomination_20), activity.getString(R.string.denomination_50_vip),
                activity.getString(R.string.denomination_100_vip) };
    }

    AlertDialog.Builder denominationBuilder = new AlertDialog.Builder(activity);
    denominationBuilder.setTitle(R.string.choose_a_denomination);
    denominationBuilder.setSingleChoiceItems(items, Arrays.asList(items).indexOf(mCurrentDenomination),
            new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int item) {
                    dialog.dismiss();
                    // TODO: Add VIP check
                    mOnDenominationChosenListener.onDenominationChosen(items[item].toString());
                }

            });
    return denominationBuilder.create();
}

From source file:com.dvdprime.mobile.android.task.ViewDeleteTask.java

/**
 * Constructor./*from  www. j ava 2 s . c  om*/
 * 
 * @param context
 */
public ViewDeleteTask(Activity activity) {
    super();
    this.mActivity = activity;
    mProgressDialog = ProgressDialog.show(activity, "", activity.getString(R.string.view_deleting_message));
    mProgressDialog.setCanceledOnTouchOutside(false);
    mProgressDialog.setCancelable(true);
    mProgressDialog.setOnCancelListener(new OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dlg) {
            DpApp.getRequestQueue().cancelAll(TAG);
        }
    });
}

From source file:de.baumann.browser.helper.helper_main.java

public static void grantPermissionsStorage(final Activity from) {

    final SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(from);

    if (android.os.Build.VERSION.SDK_INT >= 23) {
        if (sharedPref.getBoolean("perm_notShow", false)) {
            int hasWRITE_EXTERNAL_STORAGE = from
                    .checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE);
            if (hasWRITE_EXTERNAL_STORAGE != PackageManager.PERMISSION_GRANTED) {
                if (!from.shouldShowRequestPermissionRationale(Manifest.permission.WRITE_EXTERNAL_STORAGE)) {

                    new AlertDialog.Builder(from).setTitle(R.string.app_permissions_title)
                            .setMessage(helper_main.textSpannable(from.getString(R.string.app_permissions)))
                            .setNeutralButton(R.string.toast_notAgain, new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int which) {
                                    dialog.cancel();
                                    sharedPref.edit().putBoolean("perm_notShow", false).apply();
                                }//from www.  ja  v a2  s.  co m
                            }).setPositiveButton(from.getString(R.string.toast_yes),
                                    new DialogInterface.OnClickListener() {
                                        @Override
                                        public void onClick(DialogInterface dialog, int which) {
                                            if (android.os.Build.VERSION.SDK_INT >= 23)
                                                from.requestPermissions(
                                                        new String[] {
                                                                Manifest.permission.WRITE_EXTERNAL_STORAGE },
                                                        REQUEST_CODE_ASK_PERMISSIONS);
                                        }
                                    })
                            .setNegativeButton(from.getString(R.string.toast_cancel), null).show();
                    return;
                }
                from.requestPermissions(new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE },
                        REQUEST_CODE_ASK_PERMISSIONS);
            }
        }
    }
}

From source file:org.thialfihar.android.apg.service.ApgIntentServiceHandler.java

public ApgIntentServiceHandler(Activity activity, int progressDialogMessageId, int progressDialogStyle,
        boolean cancelable, OnCancelListener onCancelListener) {
    this(activity, activity.getString(progressDialogMessageId), progressDialogStyle, cancelable,
            onCancelListener);//from www. j  av  a  2s  . com
}

From source file:com.google.samples.apps.topeka.fragment.CategorySelectionFragment.java

private void startQuizActivityWithTransition(Activity activity, View toolbar, Category category) {

    final Pair[] pairs = TransitionHelper.createSafeTransitionParticipants(activity, false,
            new Pair<>(toolbar, activity.getString(R.string.transition_toolbar)));
    @SuppressWarnings("unchecked")
    ActivityOptionsCompat sceneTransitionAnimation = ActivityOptionsCompat
            .makeSceneTransitionAnimation(activity, pairs);

    // Start the activity with the participants, animating from one to the other.
    final Bundle transitionBundle = sceneTransitionAnimation.toBundle();
    Intent startIntent = QuizActivity.getStartIntent(activity, category);
    ActivityCompat.startActivityForResult(activity, startIntent, REQUEST_CATEGORY, transitionBundle);
}

From source file:com.activiti.android.app.fragments.HelpDialogFragment.java

private String getUrl(Activity activity) {
    String prefix = activity.getString(R.string.docs_prefix);
    String urlValue = null;/*from   ww  w  .  jav a 2 s.  c o m*/
    if (TextUtils.isEmpty(prefix)) {
        isDefault = true;
        urlValue = activity.getString(R.string.help_user_guide_default_url);
    } else {
        isDefault = false;
        urlValue = String.format(activity.getString(R.string.help_user_guide_url), prefix);
    }
    return urlValue;
}

From source file:com.altcanvas.twitspeak.TwitterTask.java

public void onPostExecute(TwitterTask.Payload payload) {
    Object[] data = (Object[]) payload.data;
    switch (payload.taskType) {
    case FRIENDS_TIMELINE_DLOAD2:
        Activity activity = (Activity) data[0];
        if (payload.result == null) {
            String msg = (payload.exception == null) ? activity.getString(R.string.unkexcstr)
                    : payload.exception.toString();
            G.toast(activity, msg);//from  w w w .  j a  va2  s.c o m
        } else {
            G.toast(activity, activity.getString(R.string.donestr));
        }
        break;

    case FRIENDS_TIMELINE_DLOAD:
        TwitSpeakActivity app = (TwitSpeakActivity) data[0];
        if (payload.result == null) {
            String msg = (payload.exception == null) ? app.getString(R.string.unkexcstr)
                    : payload.exception.toString();
            G.toast(app, msg);
        } else {
            Twit twit = app.db.getLatestTwit();
            app.db.markShown(twit);
            app.speak(twit);
        }
        break;
    case UPDATE:
        activity = (Activity) data[0];
        if (payload.result == null) {
            G.toast(activity, "Update failed");
        } else {
            G.toast(activity, "Update posted");
        }
        break;
    }
}

From source file:com.nbplus.vbroadlauncher.hybrid.RegisterWebViewClient.java

public RegisterWebViewClient(Activity activity, WebView view) {
    super(activity, view, activity.getString(R.string.app_name), activity.getString(R.string.app_name));
    mWebView.setWebViewClient(this);
    mWebView.addJavascriptInterface(this, JAVASCRIPT_IF_NAME);
}