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, Object... formatArgs) 

Source Link

Document

Returns a localized formatted string from the application's package's default string table, substituting the format arguments as defined in java.util.Formatter and java.lang.String#format .

Usage

From source file:com.battlelancer.seriesguide.util.ShareUtils.java

public static void shareShow(Activity activity, int showTvdbId, String showTitle) {
    String message = activity.getString(R.string.share_checkout, showTitle) + " "
            + TraktTools.buildEpisodeOrShowUrl(showTvdbId, -1, -1);
    startShareIntentChooser(activity, message, R.string.share_show);
}

From source file:com.battlelancer.seriesguide.util.ShareUtils.java

public static void shareMovie(Activity activity, int movieTmdbId, String movieTitle) {
    String message = activity.getString(R.string.share_checkout, movieTitle) + " "
            + TraktTools.buildMovieUrl(movieTmdbId);
    startShareIntentChooser(activity, message, R.string.share_movie);
}

From source file:com.battlelancer.seriesguide.util.ShareUtils.java

public static void shareEpisode(Activity activity, int showTvdbId, int seasonNumber, int episodeNumber,
        String showTitle, String episodeTitle) {
    String message = activity.getString(R.string.share_checkout,
            showTitle + " " + Utils.getNextEpisodeString(activity, seasonNumber, episodeNumber, episodeTitle))
            + " " + TraktTools.buildEpisodeOrShowUrl(showTvdbId, seasonNumber, episodeNumber);
    startShareIntentChooser(activity, message, R.string.share_episode);
}

From source file:com.mediatek.contacts.activities.ActivitiesUtils.java

/** Fix CR ALPS00839693,the "Phone" should be translated into Chinese */
public static void setAccountName(final TextView textView, final AccountWithDataSet account,
        Activity activity) {
    if (AccountTypeUtils.ACCOUNT_NAME_LOCAL_PHONE.equals(account.name)) {
        textView.setText(activity.getString(R.string.contact_editor_prompt_one_account,
                activity.getString(R.string.account_phone_only)));
    } else {//ww w  . j  a  va2  s  . c o  m
        textView.setText(activity.getString(R.string.contact_editor_prompt_one_account, account.name));
    }
    // set ellip size for extra large font size
    textView.setSingleLine();
    textView.setEllipsize(TruncateAt.END);
}

From source file:com.vuze.android.remote.RemoteUtils.java

public static void createCoreProfile(final Activity activity, final OnCoreProfileCreated l) {
    AndroidUtilsUI.requestPermissions(activity, new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE },
            new Runnable() {
                @Override/*  w  w w  . java  2s  .com*/
                public void run() {
                    RemoteProfile localProfile = new RemoteProfile(RemoteProfile.TYPE_CORE);
                    localProfile.setHost("localhost");
                    localProfile.setPort(9092);
                    localProfile.setNick(activity.getString(R.string.local_name, android.os.Build.MODEL));
                    localProfile.setUpdateInterval(2);

                    if (l != null) {
                        l.onCoreProfileCreated(localProfile);
                    }
                }
            }, new Runnable() {
                @Override
                public void run() {
                    AndroidUtils.showDialog(activity, "Permission Denied",
                            "Can't create torrent client on device without requested " + "permissions.");
                }
            });
}

From source file:com.android.tv.dvr.ui.DvrUiHelper.java

/**
 * Handle the request of recording a future program. It will handle creating schedules and
 * shows the proper toast message.//from  w w w .j  a  va 2 s. c  om
 *
 * @param addProgramToSeries denotes whether the program to be recorded should be added into
 *                           the series recording when users choose to record the entire series.
 */
public static void requestRecordingFutureProgram(Activity activity, Program program,
        boolean addProgramToSeries) {
    if (DvrUiHelper.handleCreateSchedule(activity, program, addProgramToSeries)) {
        String msg = activity.getString(R.string.dvr_msg_program_scheduled, program.getTitle());
        ToastUtils.show(activity, msg, Toast.LENGTH_SHORT);
    }
}

From source file:com.felkertech.n.ActivityUtils.java

public static void openAbout(final Activity activity) {
    try {//from   w w  w  .j  ava 2 s  .co m
        PackageInfo pInfo = activity.getPackageManager().getPackageInfo(activity.getPackageName(), 0);
        new MaterialDialog.Builder(activity).title(R.string.app_name).theme(Theme.DARK)
                .content(activity.getString(R.string.about_app_description, pInfo.versionName))
                .positiveText(R.string.website).negativeText(R.string.help)
                .callback(new MaterialDialog.ButtonCallback() {
                    @Override
                    public void onPositive(MaterialDialog dialog) {
                        super.onPositive(dialog);
                        String url = activity.getString(R.string.website_url);
                        CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
                        CustomTabsIntent customTabsIntent = builder.build();
                        try {
                            customTabsIntent.launchUrl(activity, Uri.parse(url));
                        } catch (Exception e) {
                            // There is no way to view the website.
                            activity.startActivity(new Intent(activity, HomepageWebViewActivity.class));
                        }
                    }

                    @Override
                    public void onNegative(MaterialDialog dialog) {
                        super.onNegative(dialog);
                        ActivityUtils.openIntroVoluntarily(activity);
                    }
                }).show();
    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
    }
}

From source file:us.rader.tapset.ItemListActivity.java

/**
 * Handle the response from a request to write to a {@link Tag}
 * /*from  w  w  w .j a va2 s  .  c  o  m*/
 * @param activity
 *            the {@link Activity} that received the result
 * 
 * @param resultCode
 *            the result code passed by {@link WriteTagActivity} using
 *            {@link Activity#setResult(int)} or
 *            {@link Activity#setResult(int, Intent)}
 * 
 * @param resultIntent
 *            the result {@link Intent} passed by the
 *            {@link WriteTagActivity} using
 *            {@link Activity#setResult(int, Intent)} (may be
 *            <code>null</code>)
 */
public static void handleWriteTagResult(Activity activity, int resultCode, Intent resultIntent) {

    if (resultCode == RESULT_CANCELED) {

        Toast.makeText(activity, R.string.cancelled, Toast.LENGTH_SHORT).show();
        return;

    }

    NdefMessage message = resultIntent.getParcelableExtra(NdefReaderActivity.EXTRA_RESULT);

    if (message == null) {

        Toast.makeText(activity, R.string.null_message, Toast.LENGTH_LONG).show();
        return;

    }

    byte[] bytes = message.toByteArray();
    String text = activity.getString(R.string.success_writing_tag, bytes.length);
    Toast.makeText(activity, text, Toast.LENGTH_LONG).show();

}

From source file:com.normsstuff.maps4norm.Dialogs.java

public static void saveMarks(final Activity c, final Stack<LatLng> trace) {
    final File destination;
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.FROYO
            && Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
        destination = API8Wrapper.getExternalFilesDir(c);
    } else {//w  w w .  j a v  a 2  s  . c o m
        destination = c.getDir("traces", Context.MODE_PRIVATE);
    }

    AlertDialog.Builder b = new AlertDialog.Builder(c);
    b.setTitle(R.string.save);
    final View layout = c.getLayoutInflater().inflate(R.layout.dialog_enter_filename, null);
    ((TextView) layout.findViewById(R.id.location))
            .setText(c.getString(R.string.file_path, destination.getAbsolutePath() + "/"));
    b.setView(layout);
    b.setPositiveButton(R.string.save, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            try {
                String fname = ((EditText) layout.findViewById(R.id.filename)).getText().toString();
                if (fname == null || fname.length() < 1) {
                    fname = "MapsMeasure_" + System.currentTimeMillis();
                }
                final File f = new File(destination, fname + ".csv");
                Util.saveToFile(f, trace);

                Toast.makeText(c, c.getString(R.string.file_saved, f.getAbsolutePath()), Toast.LENGTH_SHORT)
                        .show();
            } catch (Exception e) {
                Toast.makeText(c,
                        c.getString(R.string.error, e.getClass().getSimpleName() + "\n" + e.getMessage()),
                        Toast.LENGTH_LONG).show();
            }
        }
    });
    b.create().show();

}

From source file:com.todoroo.astrid.activity.FilterListFragment.java

/**
 * Creates a shortcut on the user's home screen
 *
 * @param shortcutIntent// w  w w .  j  a v  a2  s . c  o m
 * @param label
 */
private static void createShortcut(Activity activity, Filter filter, Intent shortcutIntent, String label) {
    if (label.length() == 0)
        return;

    Bitmap bitmap = superImposeListIcon(activity, filter.listingIcon, filter.listingTitle);

    Intent createShortcutIntent = new Intent();
    createShortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
    createShortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, label);
    createShortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON, bitmap);
    createShortcutIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT"); //$NON-NLS-1$

    activity.sendBroadcast(createShortcutIntent);
    Toast.makeText(activity, activity.getString(R.string.FLA_toast_onCreateShortcut, label), Toast.LENGTH_LONG)
            .show();
}