Context getString - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Context getString method.

This code example shows how to use the following methods:getString, getPackageName, getResources
This code example shows how to use the following methods:getString
                context.getString(android.R.string.no), iconId, listener);
    } 
 
    public static AlertDialog.Builder newYesNoDialog(final Context context, int titleId,
            int messageId, int iconId, OnClickListener listener) {
        return newYesNoDialog(context, context.getString(titleId), context.getString(messageId),
                context.getString(android.R.string.yes), context.getString(android.R.string.no),
                iconId, listener);
    } 
 
    public static AlertDialog.Builder newYesNoDialog(final Context context, int titleId,
            int messageId, int positiveButtonMessageId, int negativeButtonMessageId, int iconId,
            OnClickListener listener) {
        return newYesNoDialog(context, context.getString(titleId), context.getString(messageId),
                context.getString(positiveButtonMessageId),
                context.getString(negativeButtonMessageId), iconId, listener);
    } 
 
    /** 
     * Builds a new AlertDialog to display a simple message 
8
CodeRank
This code example shows how to use the following methods:startActivity, getString
8
CodeRank
This code example shows how to use the following methods:getPackageManager, getPackageName, getString, newInstance
	} 
 
	private <T> T doRequest(HttpRequestBase request, ResponseHandler<T> responseHandler) {
		mHttpRequest = request;
 
		AndroidHttpClient client = AndroidHttpClient.newInstance(getUserAgent(), mContext);
		AndroidHttpClient.modifyRequestToAcceptGzipResponse(mHttpRequest);
 
		HttpParams httpParameters = client.getParams();
		HttpConnectionParams.setSoTimeout(httpParameters, 100000);
 
		try { 
			return client.execute(mHttpRequest, responseHandler);
		} 
		catch (IOException e) {
			Log.e("Server request failed.", e);
		} 
		finally { 
			client.close();
		} 

7
CodeRank
This code example shows how to use the following methods:getPackageName, getResources, getString
     * @param resourceName 
     * @param resourceType 
     * @return 
     */ 
    public static int getDynamicResourceId(Context context, String resourceName, String resourceType) {
        return context.getResources().getIdentifier(resourceName, resourceType, context.getPackageName());
    } 
     
    /** 
     * Gets resource string dynamically 
     *  
     * @param context 
     * @param resourceName 
     * @return 
     */ 
    public static String getDynamicResourceString(Context context, String resourceName) {
        int resourceId = getDynamicResourceId(context, resourceName, "string");
        return context.getString(resourceId);
    } 
} 

7
CodeRank
This code example shows how to use the following methods:getPackageManager, getString, startActivity
		intent.setData(Uri.parse(url));
		context.startActivity(intent);
	} 
 
	public static void startEmailActivity(Context context, int toResId, int subjectResId, int bodyResId) {
		startEmailActivity(context, context.getString(toResId), context.getString(subjectResId),
				context.getString(bodyResId));
	} 
 
	public static void startEmailActivity(Context context, String to, String subject, String body) {
		final Intent intent = new Intent(Intent.ACTION_SEND);
		intent.setType("message/rfc822");
 
		if (!TextUtils.isEmpty(to)) {
			intent.putExtra(Intent.EXTRA_EMAIL, new String[] { to });
		} 
		if (!TextUtils.isEmpty(subject)) {
			intent.putExtra(Intent.EXTRA_SUBJECT, subject);
		} 
		if (!TextUtils.isEmpty(body)) {

7
CodeRank
This code example shows how to use the following methods:runOnUiThread, getString, makeText
     * @param resId The resource identifier of the message string 
     * @param formatArgs The format arguments that will be used for substitution. 
     */ 
    public static void showToast( Activity activity, int resId, Object... formatArgs )
    { 
        showToast( activity, activity.getString( resId, formatArgs ) );
    } 
     
    /** 
     * Pop up a temporary message on the device. 
     * @param activity The activity to display from 
     * @param message The message string to display. 
     */ 
    public static void showToast( Activity activity, String message )
    { 
        if( activity == null )
            return; 
         
        if( sToast != null )
        { 

7
CodeRank
This code example shows how to use the following methods:getString
        mContextView.setSubtitle(subtitle);
    } 
 
    @Override 
    public void setTitle(int resId) {
        setTitle(mContext.getString(resId));
    } 
 
    @Override 
    public void setSubtitle(int resId) {
        setSubtitle(mContext.getString(resId));
    } 
 
    @Override 
    public void setCustomView(View view) {
        mContextView.setCustomView(view);
        mCustomView = view != null ? new WeakReference<View>(view) : null;
    } 
 
    @Override 
7
CodeRank
This code example shows how to use the following methods:getString
	protected ProgressTask(Activity activity) {
		this(activity, R.string.loading_);
	} 
 
	protected ProgressTask(Activity activity, int message) {
		super(activity);
		this.dialog = new ProgressDialog(activity);
		this.dialog.setCancelable(true);
		this.dialog.setIndeterminate(true);
		this.dialog.setMessage(activity.getString(message));
	} 
	 
	public void register(ProgressCallback callback) {
		this.callback = callback;
	} 
 
	@Override 
	protected void onPreExecute() { 
		super.onPreExecute(); 
		dialog.show();
7
CodeRank
This code example shows how to use the following methods:getString
		this(context, null);
	} 
 
	public MenuImpl(final Context context, final MenuAdapter adapter) {
		mMenuItems = new Menus(adapter);
		mContext = context;
	} 
 
	@Override 
	public MenuItem add(final CharSequence title) {
		return add(0, 0, 0, title);
	} 
 
	@Override 
	public MenuItem add(final int titleRes) {
		return add(0, 0, 0, titleRes);
	} 
 
	@Override 
	public MenuItem add(final int groupId, final int itemId, final int order, final CharSequence title) {

7
CodeRank

Related Context getString Questions & Answers:

Other Context getString Examples

94:	        Notification notification = new Notification(icon, message, when);
95:	        
96:	        String title = context.getString(R.string.app_name);
97:	        
98:	        Intent notificationIntent = new Intent(context, MainActivity.class);

Read More

47:	                displayMessage(context, context.getString(
48:	                        R.string.server_registering, i, MAX_ATTEMPTS));
49:	                post(serverUrl, params);
50:	                GCMRegistrar.setRegisteredOnServer(context, true);
51:	                String message = context.getString(R.string.server_registered);
-
55:	                // Here we are simplifying and retrying on any error; in a real
56:	                // application, it should retry only on unrecoverable errors
57:	                // (like HTTP error code 503).
58:	                Log.e(TAG, "Failed to register on attempt " + i + ":" + e);
59:	                if (i == MAX_ATTEMPTS) {

Read More

getString Method Overview
Return a localized string from the application's package's default string table.
See Code Examples for other Android Context Methods: