当前位置: 首页>>代码示例>>Java>>正文


Java Activity.getString方法代码示例

本文整理汇总了Java中android.app.Activity.getString方法的典型用法代码示例。如果您正苦于以下问题:Java Activity.getString方法的具体用法?Java Activity.getString怎么用?Java Activity.getString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.app.Activity的用法示例。


在下文中一共展示了Activity.getString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: callDialogMsgPosNeg

import android.app.Activity; //导入方法依赖的package包/类
public static void callDialogMsgPosNeg(Activity activity, String msgId, int yes, int no, OnClickListener yesListener, OnClickListener noListener) {
    TipBean dialogMsgByMsg = TipUtils.getTipBean(msgId);
    if (activity != null && dialogMsgByMsg != null) {
        CharSequence string;
        Builder builder = new Builder(activity);
        if ("".equals(dialogMsgByMsg.title) || dialogMsgByMsg.title == null) {
            string = activity.getString(2131100003);
        } else {
            string = dialogMsgByMsg.title;
        }
        Dialog dialog = builder.setTitle(string).setIcon(2130837921).setMessage(dialogMsgByMsg.message).setCancelable(false).setPositiveButton(yes, yesListener).setNegativeButton(no, noListener).create();
        if (!activity.isFinishing() && !activity.isRestricted()) {
            try {
                dialog.show();
            } catch (Exception e) {
            }
        }
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:20,代码来源:UIs.java

示例2: checkInternetPermission

import android.app.Activity; //导入方法依赖的package包/类
boolean checkInternetPermission() {
    if (checkedInternetPermission) {
        return true;
    }

    int permissionCheck = checkPermission(Manifest.permission.INTERNET);
    if (permissionCheck != PackageManager.PERMISSION_GRANTED) {
        Activity activity = getActivity();
        String errorType = activity.getString(R.string.com_facebook_internet_permission_error_title);
        String errorDescription = activity.getString(R.string.com_facebook_internet_permission_error_message);
        complete(Result.createErrorResult(pendingRequest, errorType, errorDescription));

        return false;
    }

    checkedInternetPermission = true;
    return true;
}
 
开发者ID:eviltnan,项目名称:kognitivo,代码行数:19,代码来源:LoginClient.java

示例3: tab_1

import android.app.Activity; //导入方法依赖的package包/类
public static String tab_1 (Activity activity) {
    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(activity);
    String s;

    final String tab_string = sharedPref.getString("tab_0", "");

    try {
        if (tab_string.isEmpty()) {
            s = activity.getString(R.string.context_tab);
        } else {
            s = tab_string;
        }
    } catch (Exception e) {
        Log.e("KidsPortal", "Unable to get String", e);
        s = activity.getString(R.string.context_tab);
    }
    return s;
}
 
开发者ID:JaeNuguid,项目名称:Kids-Portal-Android,代码行数:19,代码来源:helper_browser.java

示例4: showStorageToast

import android.app.Activity; //导入方法依赖的package包/类
public static void showStorageToast(Activity activity, int remaining) {
    String noStorageText = null;
    if (remaining == NO_STORAGE_ERROR) {

        String state = Environment.getExternalStorageState();
        if (state.equals(Environment.MEDIA_CHECKING)) {

            noStorageText = activity.getString(R.string.preparing_card);
        } else {

            noStorageText = activity.getString(R.string.no_storage_card);
        }
    } else if (remaining < 1) {

        noStorageText = activity.getString(R.string.not_enough_space);
    }

    if (noStorageText != null) {
        MagicToast.showError(activity, noStorageText);
    }
}
 
开发者ID:SalmanTKhan,项目名称:MyAnimeViewer,代码行数:22,代码来源:CropImage.java

示例5: getDomain

import android.app.Activity; //导入方法依赖的package包/类
public static String getDomain (Activity activity, String url) {
    String domain;
    try {
        if(Uri.parse(url).getHost().length() == 0) {
            domain = activity.getString(R.string.app_domain);
        } else if (Uri.parse(url).getHost().contains("startpage.de") || Uri.parse(url).getHost().contains("startpage.com")){
            domain = "startpage.com";
        } else {
            domain = Uri.parse(url).getHost().replace("www.", "");
        }
    } catch (Exception e) {
        Log.e(TAG, "Unable to get domain", e);
        domain = activity.getString(R.string.app_domain);
    }
    return domain ;
}
 
开发者ID:JaeNuguid,项目名称:Kids-Portal-Android,代码行数:17,代码来源:helper_webView.java

示例6: checkNetwork

import android.app.Activity; //导入方法依赖的package包/类
private static boolean checkNetwork(boolean network, @NonNull final Activity context,
                             @Nullable Runnable noNetworkPreDialogListener,
                             @Nullable Runnable onDonePressedListener,
                             @Nullable Runnable onAfterSettingsListener,
                             @Nullable Runnable onDismissListener) {
    if (!network) {
        Log.i(TAG, "Network unavailable. Context " + context.getClass().getSimpleName());

        sDonePressedListeners.enqueue(onDonePressedListener);
        sAfterSettingsListeners.enqueue(onAfterSettingsListener);
        sDismissListeners.enqueue(onDismissListener);

        if (!sDisplayingDialog) {
            sDisplayingDialog = true;

            boolean airplaneMode = isAirplaneModeEnabled(context);
            String additionalInfo =
                    context.getString(
                            airplaneMode ? R.string.airplane : R.string.enable_network);
            setNetworkDialog(context, airplaneMode, additionalInfo);
        } else if (noNetworkPreDialogListener != null) {
            noNetworkPreDialogListener.run();
        }
    }
    return network;
}
 
开发者ID:ArnauBlanch,项目名称:civify-app,代码行数:27,代码来源:NetworkController.java

示例7: showSttArchiveDialog

import android.app.Activity; //导入方法依赖的package包/类
public static void showSttArchiveDialog(Activity activity, Callback.a1<String> callback) {
    SearchOrCustomTextDialog.DialogOptions dopt = new SearchOrCustomTextDialog.DialogOptions();
    baseConf(activity, dopt);
    dopt.callback = callback;
    List<String> highlightedData = new ArrayList<>();
    List<String> availableData = new ArrayList<>();
    availableData.add("archive.txt");
    availableData.add("done.txt");
    availableData.add("todo.done.txt");
    availableData.add("todo.archive.txt");
    String hl = new AppSettings(activity).getLastTodoUsedArchiveFilename();
    if (!TextUtils.isEmpty(hl)) {
        highlightedData.add(hl);
        if (!availableData.contains(hl)) {
            availableData.add(hl);
        }
    }

    dopt.data = availableData;
    dopt.highlightData = highlightedData;
    dopt.titleText = R.string.archive;
    dopt.searchHintText = R.string.search_hint__add_or_custom;
    dopt.messageText = activity.getString(R.string.archive_does_move_done_tasks);
    SearchOrCustomTextDialog.showMultiChoiceDialogWithSearchFilterUI(activity, dopt);
}
 
开发者ID:gsantner,项目名称:markor,代码行数:26,代码来源:SearchOrCustomTextDialogCreator.java

示例8: showPriorityDialog

import android.app.Activity; //导入方法依赖的package包/类
public static void showPriorityDialog(Activity activity, char selectedPriority, Callback.a1<String> callback) {
    SearchOrCustomTextDialog.DialogOptions dopt = new SearchOrCustomTextDialog.DialogOptions();
    baseConf(activity, dopt);
    dopt.callback = callback;

    List<String> availableData = new ArrayList<>();
    List<String> highlightedData = new ArrayList<>();
    String none = activity.getString(R.string.none);
    availableData.add(none);
    for (int i = ((int) 'A'); i <= ((int) 'Z'); i++) {
        availableData.add(Character.toString((char) i));
    }
    highlightedData.add(none);
    if (selectedPriority != SttTask.PRIORITY_NONE) {
        highlightedData.add(Character.toString(selectedPriority));
    }

    dopt.data = availableData;
    dopt.highlightData = highlightedData;
    dopt.titleText = R.string.priority;
    dopt.searchHintText = R.string.search_hint__add_or_custom;
    dopt.messageText = "";
    dopt.isSearchEnabled = false;
    SearchOrCustomTextDialog.showMultiChoiceDialogWithSearchFilterUI(activity, dopt);
}
 
开发者ID:gsantner,项目名称:markor,代码行数:26,代码来源:SearchOrCustomTextDialogCreator.java

示例9: tab_2

import android.app.Activity; //导入方法依赖的package包/类
public static String tab_2 (Activity activity) {
    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(activity);
    String s;

    final String tab_string = sharedPref.getString("tab_1", "");

    try {
        if (tab_string.isEmpty()) {
            s = activity.getString(R.string.context_tab);
        } else {
            s = tab_string;
        }
    } catch (Exception e) {
        Log.e("KidsPortal", "Unable to get String", e);
        s = activity.getString(R.string.context_tab);
    }
    return s;
}
 
开发者ID:JaeNuguid,项目名称:Kids-Portal-Android,代码行数:19,代码来源:helper_browser.java

示例10: createShortcut

import android.app.Activity; //导入方法依赖的package包/类
/**
 * Creates a shortcut on the homescreen using the
 * {@link HistoryItem} information that opens the
 * browser. The icon, URL, and title are used in
 * the creation of the shortcut.
 *
 * @param activity the activity needed to create
 *                 the intent and show a snackbar message
 * @param item     the HistoryItem to create the shortcut from
 */
public static void createShortcut(@NonNull Activity activity, @NonNull HistoryItem item) {
    if (TextUtils.isEmpty(item.getUrl())) {
        return;
    }
    Log.d(TAG, "Creating shortcut: " + item.getTitle() + ' ' + item.getUrl());
    Intent shortcutIntent = new Intent(activity, MainActivity.class);
    shortcutIntent.setData(Uri.parse(item.getUrl()));

    final String title = TextUtils.isEmpty(item.getTitle()) ? activity.getString(R.string.untitled) : item.getTitle();

    Intent addIntent = new Intent();
    addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
    addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, title);
    addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON, item.getBitmap());
    addIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
    activity.sendBroadcast(addIntent);
    Utils.showSnackbar(activity, R.string.message_added_to_homescreen);
}
 
开发者ID:XndroidDev,项目名称:Xndroid,代码行数:29,代码来源:Utils.java

示例11: tab_5

import android.app.Activity; //导入方法依赖的package包/类
public static String tab_5 (Activity activity) {
    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(activity);
    String s;

    final String tab_string = sharedPref.getString("tab_4", "");

    try {
        if (tab_string.isEmpty()) {
            s = activity.getString(R.string.context_tab);
        } else {
            s = tab_string;
        }
    } catch (Exception e) {
        Log.e("KidsPortal", "Unable to get String", e);
        s = activity.getString(R.string.context_tab);
    }
    return s;
}
 
开发者ID:JaeNuguid,项目名称:Kids-Portal-Android,代码行数:19,代码来源:helper_browser.java

示例12: create

import android.app.Activity; //导入方法依赖的package包/类
/**
  * Prepares an alert dialog builder, using the work_dialog view.
  * <p>
  * The caller should finish populating the builder, then call AlertDialog.Builder#show().
  */
 public static AlertDialog.Builder create(Activity activity, int titleId) {
     View view;
     try {
         view = activity.getLayoutInflater().inflate(R.layout.work_dialog, null);
     } catch (InflateException ie) {
         Log.e(TAG, "Exception while inflating work dialog layout: " + ie.getMessage());
         throw ie;
     }

     String title = activity.getString(titleId);
     AlertDialog.Builder builder = new AlertDialog.Builder(activity);
     builder.setTitle(title);
     builder.setView(view);
     return builder;
}
 
开发者ID:AndyZhu1991,项目名称:grafika,代码行数:21,代码来源:WorkDialog.java

示例13: display

import android.app.Activity; //导入方法依赖的package包/类
/**
 * Displays the About box.  An AlertDialog is created in the calling activity's context.
 * <p>
 * The box will disappear if the "OK" button is touched, if an area outside the box is
 * touched, if the screen is rotated ... doing just about anything makes it disappear.
 */
public static void display(Activity caller) {
    String versionStr = getVersionString(caller);
    String aboutHeader = caller.getString(R.string.app_name) + " v" + versionStr;

    // Manually inflate the view that will form the body of the dialog.
    View aboutView;
    try {
        aboutView = caller.getLayoutInflater().inflate(R.layout.about_dialog, null);
    } catch (InflateException ie) {
        Log.e(TAG, "Exception while inflating about box: " + ie.getMessage());
        return;
    }

    AlertDialog.Builder builder = new AlertDialog.Builder(caller);
    builder.setTitle(aboutHeader);
    builder.setIcon(R.drawable.ic_launcher);
    builder.setCancelable(true);        // implies setCanceledOnTouchOutside
    builder.setPositiveButton(R.string.ok, null);
    builder.setView(aboutView);
    builder.show();
}
 
开发者ID:AndyZhu1991,项目名称:grafika,代码行数:28,代码来源:AboutBox.java

示例14: setActionBarUpIndicator

import android.app.Activity; //导入方法依赖的package包/类
public static void setActionBarUpIndicator(Object info, Activity activity, Drawable drawable, int contentDescRes) {
    final SetIndicatorInfo sii = (SetIndicatorInfo) info;
    if (sii.mUpIndicatorView != null) {
        sii.mUpIndicatorView.setImageDrawable(drawable);
        final String contentDescription = contentDescRes == 0 ? null : activity.getString(contentDescRes);
        sii.mUpIndicatorView.setContentDescription(contentDescription);
    }
}
 
开发者ID:ultrasonic,项目名称:ultrasonic,代码行数:9,代码来源:ActionBarHelperCompat.java

示例15: contactUs

import android.app.Activity; //导入方法依赖的package包/类
public static void contactUs(Activity activity) {
    AboutConfig config = AboutConfig.getInstance();

    final Uri mailto = Uri.fromParts("mailto", config.emailAddress, null);

    String emailBody = config.emailBody;
    if (TextUtils.isEmpty(emailBody)) {
        String deviceInfo = "";
        deviceInfo += "\n App version: " + config.version;
        deviceInfo += "\n Android version: " + Build.VERSION.RELEASE + " (" + android.os.Build.VERSION.SDK_INT + ")";
        deviceInfo += "\n Device: " + android.os.Build.MODEL + " (" + android.os.Build.PRODUCT + ")";
        deviceInfo += "\n Platform: " + platformName(config.buildType);

        emailBody = activity.getString(R.string.egab_email_body_prompt) + "\n\n\n\n\n"
                + "---------------------------" + deviceInfo;
    }

    try {
        Intent emailIntent = new Intent(Intent.ACTION_SENDTO, mailto);
        emailIntent.putExtra(Intent.EXTRA_SUBJECT, config.emailSubject);
        emailIntent.putExtra(Intent.EXTRA_TEXT, emailBody);
        activity.startActivity(Intent.createChooser(emailIntent, "Send email..."));
    } catch (Exception e) {
        if (config.analytics != null) {
            config.analytics.logException(e, false);
        }
    }
}
 
开发者ID:eggheadgames,项目名称:android-about-box,代码行数:29,代码来源:EmailUtil.java


注:本文中的android.app.Activity.getString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。