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:com.clevertrail.mobile.viewtrail.Object_TrailArticle.java

public static void loadTrailArticle(Activity activity, String sTrailName) {
    mActivity = activity;/*from   w w w.  jav a 2  s .  c  om*/
    sName = sTrailName;
    // show a progress dialog
    mPD = ProgressDialog.show(activity, "", activity.getString(R.string.progress_loading) + " " + sTrailName,
            true);

    //spin off a thread to do the actual download of the trail data
    new Thread(new Runnable() {
        public void run() {
            //call helper function which downloads data
            int error = Object_TrailArticle.loadTrailArticle_helper(mActivity, sName);
            mPD.dismiss();
            Utils.showMessage(mActivity, error);

        }
    }).start();
}

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

/**
 * ??????.//  w ww  .  j  a  va  2s  . c om
 *
 * @param activity ??Activity?????
 * @param ex
 */
public static void sendBugReport(Activity activity, Throwable ex) {
    MyLog.writeStackTrace(MyConst.getCaughtBugFilePath(), ex);

    sBugReportFile = new File(MyConst.getCaughtBugFilePath());
    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_msg2))
            .setPositiveLabel(activity.getString(R.string.send)).setPositiveClickListener(mBugDialogOkClicked)
            .setNegativeLabel(activity.getString(R.string.cancel))
            .setNegativeClickListener(mBugDialogCancelClicked).show();
}

From source file:ru.example.sic.my_ads.activity.MainActivity.java

public static void logIn(Activity activity) {
    ParseLoginBuilder builder = new ParseLoginBuilder(activity);
    Intent parseLoginIntent = builder// w w  w.  j a  v  a2s . c om
            //.setAppLogo(R.mipmap.logo_vorschau900)
            .setParseLoginEnabled(true).setParseLoginButtonText(activity.getString(R.string.login_text))
            .setParseLoginEmailAsUsername(true).build();
    activity.startActivityForResult(parseLoginIntent, RC_LOGIN);
}

From source file:com.nextgis.maplibui.util.ControlHelper.java

public static void setZoomText(Activity activity, TextView text, int string, int zoom) {
    String scale = LocationUtil.formatLength(activity, MapUtil.getScaleInCm(activity, zoom), 0);
    text.setText(String.format(activity.getString(string) + "\r\n" + scale, zoom));
}

From source file:com.hemou.android.util.ToastUtils.java

/**
 * Show {@link Toast} for exception/*w  w w  . ja va 2  s  . c om*/
 * <p>
 * This given default message will be used if an message can not be derived
 * from the given {@link Exception}
 * <p>
 * This method may be called from any thread
 * 
 * @param activity
 * @param e
 * @param defaultMessage
 */
public static void show(final Activity activity, final Exception e, final int defaultMessage) {
    if (activity == null)
        return;

    String message;
    // if (e instanceof RequestException)
    // message = ((RequestException) e).formatErrors();
    if (e instanceof NotAuthorizedException)
        message = ((NotAuthorizedException) e).getLocalizedMessage();
    else
        message = null;

    if (TextUtils.isEmpty(message))
        message = activity.getString(defaultMessage);

    show(activity, message);
}

From source file:org.benetech.secureapp.activities.MainActivity.java

public static void showReceivingContactPublicKey(Activity context) {
    try {// w  ww.  ja  v  a 2  s . c  o m
        String desktopPublicKey = context.getString(R.string.public_key_desktop);
        String publicCode40 = MartusCrypto.computeFormattedPublicCode40(desktopPublicKey);
        Util.showMessage(context, publicCode40, context.getString(R.string.receiving_contact_public_key));
    } catch (Exception e) {
        Log.e(TAG, "Could not format public key", e);
        showShortToast(context, context.getString(R.string.error_message));
    }
}

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

/**
 * Creates a generic attribute and tries to save it
 * @param activity/* w ww.j ava 2  s .  co  m*/
 * @param name
 * @param value
 * @param label
 */
public static void createGenericAttribute(Activity activity, String name, String value, String label) {
    try {
        GenericAttribute attribute = GenericAttributeFactory.createAttribute(name);
        if (label != null) {
            attribute.setLabel(label);
        }
        setValueAndPersist(activity, attribute, value);
    } catch (InvalidAttributeNameException e) {
        DialogUtils.showNeutralButtonDialog(activity, activity.getString(R.string.defaultErrorDialogTitle),
                "Invalid name");
    }
}

From source file:Main.java

public static ProgressDialog createProgressDialog(final Activity activity, int progressDialogTitleId,
        int progressDialogMsgId) {
    ProgressDialog progressDialog = new ProgressDialog(activity);
    if (progressDialogTitleId > 0) {
        progressDialog.setTitle(progressDialogTitleId);
    } else {/*from  w w  w  .  j  a  va 2s .  c  o  m*/
        progressDialog.setTitle(activity.getResources().getIdentifier(PROGRESS_DIALOG_TITLE_RESOURCE, "string",
                activity.getPackageName()));
    }
    if (progressDialogMsgId > 0) {
        progressDialog.setMessage(activity.getString(progressDialogMsgId));
    } else {
        progressDialogMsgId = activity.getResources().getIdentifier(PROGRESS_DIALOG_MESSAGE_RESOURCE, "string",
                activity.getPackageName());
        progressDialog.setMessage(activity.getString(progressDialogMsgId));
    }
    progressDialog.setIndeterminate(true);
    progressDialog.setOnKeyListener(new OnKeyListener() {
        public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
            activity.onKeyDown(keyCode, event);
            return false;
        }
    });
    // progressDialog.setInverseBackgroundForced(true);
    return progressDialog;
}

From source file:fr.cph.chicago.util.Util.java

private static void showSnackBar(@NonNull final Activity activity, final int message) {
    if (activity.getCurrentFocus() != null) {
        Snackbar.make(activity.getCurrentFocus(), activity.getString(message), Snackbar.LENGTH_SHORT).show();
    } else {//from   w w  w.  j av a2s  .  c om
        Toast.makeText(activity, activity.getString(message), Toast.LENGTH_LONG).show();
    }
}

From source file:de.luhmer.owncloudnewsreader.LoginDialogFragment.java

public static void ShowAlertDialog(String title, String text, Activity activity) {
    AlertDialog.Builder aDialog = new AlertDialog.Builder(activity);
    aDialog.setTitle(title);//from   w ww . ja v a 2s .co  m
    aDialog.setMessage(text);
    aDialog.setPositiveButton(activity.getString(android.R.string.ok), null);
    aDialog.create().show();
}