當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。