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


Java StringRequest类代码示例

本文整理汇总了Java中com.android.volley.toolbox.StringRequest的典型用法代码示例。如果您正苦于以下问题:Java StringRequest类的具体用法?Java StringRequest怎么用?Java StringRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: getPhone

import com.android.volley.toolbox.StringRequest; //导入依赖的package包/类
private void getPhone(String str) {
    String url="https://www.iteblog.com/api/mobile.php?mobile="+str+"";
    RequestQueue queue = Volley.newRequestQueue(this);
    StringRequest request = new StringRequest(Method.PUBLIC, url,
            new Response.Listener<String>() {
                // 成功
                @Override
                public void onResponse(String json) {
                    Volley_Json(json);
                    //Toast.makeText(MainActivity.this, "成功:"+json, Toast.LENGTH_SHORT).show();
                }
            }, new Response.ErrorListener() {
        // 失败
        @Override
        public void onErrorResponse(VolleyError errorLog) {
            Toast.makeText(MainActivity.this, "失败:"+errorLog.toString(), Toast.LENGTH_LONG).show();
            Log.d("TGA","失败:"+errorLog.toString());
        }
    });
    queue.add(request);

}
 
开发者ID:xiaolunan,项目名称:Attribution,代码行数:23,代码来源:MainActivity.java

示例2: check

import com.android.volley.toolbox.StringRequest; //导入依赖的package包/类
public void check(final Callback callback) {
    mCallback = callback;
    StringRequest request = new StringRequest(Request.Method.GET, UPDATE_URL, this, this);
    request.setRetryPolicy(new DefaultRetryPolicy(mTimeOut, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
    request.setTag("update-check");
    request.setShouldCache(false);
    mRequestQueue.add(request);
}
 
开发者ID:feifadaima,项目名称:https-github.com-hyb1996-NoRootScriptDroid,代码行数:9,代码来源:UpdateChecker.java

示例3: post

import com.android.volley.toolbox.StringRequest; //导入依赖的package包/类
/**
 * 根据地址和请求参数 发送POST请求
 * @param url   地址服务器地址
 * @param listener  数据加载回调接口
 * @param params  请求参数
 */
public void post(String url, final Fdv_CallBackListener<String> listener,Map<String,String> params){
    StringRequest stringRequest=new StringRequest(Request.Method.POST, url, new Response.Listener<String>() {
        @Override
        public void onResponse(String response) {
            if(listener!=null){
                listener.onSuccessResponse(response);
            }
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            if(listener!=null){
                listener.onErrorResponse(error);
            }
        }
    });
    addRequest(stringRequest,params);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:25,代码来源:Fdv_StringRequest.java

示例4: load

import com.android.volley.toolbox.StringRequest; //导入依赖的package包/类
public void load(String url, final OnStringListener listener) {
    StringRequest request = new StringRequest(url, new Response.Listener<String>() {
        @Override
        public void onResponse(String s) {
            listener.onSuccess(s);
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError volleyError) {
            listener.onError(volleyError);
        }
    });

    request.setRetryPolicy(new DefaultRetryPolicy(DefaultRetryPolicy.DEFAULT_TIMEOUT_MS,
            DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
            DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));

    VolleySingleton.getVolleySingleton(context).addToRequestQueue(request);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:StringModelImpl.java

示例5: execute

import com.android.volley.toolbox.StringRequest; //导入依赖的package包/类
public void execute() {
    final String url = URL + "/sync";
    isSyncing = true;
    StringRequest req = new StringRequest(Request.Method.POST, url, this, this) {
        @Override
        public HashMap<String, String> getHeaders() {
            return getDefaultHeaders();
        }

        @Override
        public byte[] getBody() throws AuthFailureError {
            Map<String, String> params = new HashMap<>();
            params.put("username", mUsername);
            params.put("lastSyncedTime", String.valueOf(mLastSyncedTimeEpoch));
            return new JSONObject(params).toString().getBytes();
        }
    };

    req.setRetryPolicy(new DefaultRetryPolicy(
            ASYNC_CONNECTION_EXTENDED_TIMEOUT,
            DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
            0));
    VolleyRequestQueue.getInstance().addToRequestQueue(req);
}
 
开发者ID:Q115,项目名称:Goalie_Android,代码行数:25,代码来源:RESTSync.java

示例6: get

import com.android.volley.toolbox.StringRequest; //导入依赖的package包/类
/**
 * get request
 *
 * @param url
 * @param callback
 */
@Override
public void get(String url, final IRequestCallback callback) {
    StringRequest request = new StringRequest(Request.Method.GET, url,
            new Response.Listener<String>() {
                @Override
                public void onResponse(String response) {
                    callback.onSuccess(response);
                }
            }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            callback.onFailure(error);
        }
    });
    mQueue.add(request);
}
 
开发者ID:Res2013,项目名称:MyCleanArchitecture,代码行数:23,代码来源:VolleyRequestManager.java

示例7: volleyGetStringRequest

import com.android.volley.toolbox.StringRequest; //导入依赖的package包/类
private String volleyGetStringRequest() {
    StringRequest request = new StringRequest(Request.Method.GET, Constant.JUHE_URL_GET,
            new Response.Listener<String>() {
        @Override
        public void onResponse(String response) {
            Toast.makeText(MainActivity.this, response, Toast.LENGTH_SHORT).show();
        }
    },
            new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            Toast.makeText(MainActivity.this, error.toString(), Toast.LENGTH_SHORT).show();
        }
    });
    request.setTag(STRING_GET_TAG);
    MyApplication.getHttpQueues().add(request);
    return request.getTag().toString();
}
 
开发者ID:InnoFang,项目名称:Android-Code-Demos,代码行数:19,代码来源:MainActivity.java

示例8: onErrorResponse

import com.android.volley.toolbox.StringRequest; //导入依赖的package包/类
@Override
public void onErrorResponse(VolleyError error) {
    Log.e(TAG, "onErrorResponse: " + error.toString());
    findViewById(R.id.articleLoader).setVisibility(View.GONE);

    ConnectivityManager cm = (ConnectivityManager) getBaseContext().getSystemService(Context.CONNECTIVITY_SERVICE);
    if (cm != null) {
        NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
        if (activeNetwork == null || !activeNetwork.isConnectedOrConnecting()) {
            // Display icon
            findViewById(R.id.noNetwork).setVisibility(View.VISIBLE);
            // Display permanent message
            Snackbar.make(findViewById(R.id.coordinatorArticle), getString(R.string.error_no_connection), Snackbar.LENGTH_INDEFINITE)
                    .setAction(getString(R.string.error_no_connection_retry), new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            REQUEST_QUEUE.add(new StringRequest(Request.Method.GET, shareLink, articleReceived, errorResponse));
                        }
                    }).show();
        }
    }
}
 
开发者ID:MBach,项目名称:LeMondeRssReader,代码行数:23,代码来源:ArticleActivity.java

示例9: get

import com.android.volley.toolbox.StringRequest; //导入依赖的package包/类
@Override
public void get(String url, Map<String, Object> params, final ICallBack callback) {
    StringRequest stringRequest = new StringRequest(Request.Method.GET,
            url, new Response.Listener<String>() {
        @Override
        public void onResponse(String response) {
            callback.onSuccess(response);
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError volleyError) {
            callback.onFailed(volleyError.toString());
        }
    });
    mQueue.add(stringRequest);
}
 
开发者ID:AweiLoveAndroid,项目名称:HttpRequestProcessor,代码行数:17,代码来源:VolleyProcessor.java

示例10: post

import com.android.volley.toolbox.StringRequest; //导入依赖的package包/类
@Override
public void post(String url, Map<String, Object> params, final ICallBack callback) {
    StringRequest stringRequest = new StringRequest(Request.Method.POST,
            url, new Response.Listener<String>() {
        @Override
        public void onResponse(String response) {
            callback.onSuccess(response);
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError volleyError) {
            callback.onFailed(volleyError.toString());
        }
    });
    mQueue.add(stringRequest);
}
 
开发者ID:AweiLoveAndroid,项目名称:HttpRequestProcessor,代码行数:17,代码来源:VolleyProcessor.java

示例11: getRequest

import com.android.volley.toolbox.StringRequest; //导入依赖的package包/类
protected void getRequest()
{
    StringRequest stringGetRequest = new StringRequest(Request.Method.GET, UserPref.getNewfolderUrl(),
            new Response.Listener<String>(){
                @Override
                public void onResponse(String response)
                {

                }

            }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error)
        {
            Toast.makeText(ApplyActivity.this,error.toString(),Toast.LENGTH_SHORT).show();

        }
    });
    requestQueue.add(stringGetRequest);
}
 
开发者ID:zhirunn,项目名称:CompassDemo,代码行数:21,代码来源:ApplyActivity.java

示例12: execute

import com.android.volley.toolbox.StringRequest; //导入依赖的package包/类
public void execute() {
    final String url = URL + "/remind";
    StringRequest req = new StringRequest(Request.Method.POST, url, this, this) {
        @Override
        public HashMap<String, String> getHeaders() {
            return getDefaultHeaders();
        }

        @Override
        public byte[] getBody() throws AuthFailureError {
            Map<String, String> params = new HashMap<>();
            params.put("fromUsername", mUsername);
            params.put("toUsername", mToUsername);
            params.put("guid", mGuid);
            params.put("isRemindingRef", isRemindingRef ? "1" : "0");
            return new JSONObject(params).toString().getBytes();
        }
    };

    req.setRetryPolicy(new DefaultRetryPolicy(
            ASYNC_CONNECTION_NORMAL_TIMEOUT,
            DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
            0));
    VolleyRequestQueue.getInstance().addToRequestQueue(req);
}
 
开发者ID:Q115,项目名称:Goalie_Android,代码行数:26,代码来源:RESTRemind.java

示例13: execute

import com.android.volley.toolbox.StringRequest; //导入依赖的package包/类
public void execute() {
    final String url = URL + "/upvote";
    StringRequest req = new StringRequest(Request.Method.POST, url, this, this) {
        @Override
        public HashMap<String, String> getHeaders() {
            return getDefaultHeaders();
        }

        @Override
        public byte[] getBody() throws AuthFailureError {
            Map<String, String> params = new HashMap<>();
            params.put("username", mUsername);
            params.put("guid", mGuid);
            return new JSONObject(params).toString().getBytes();
        }
    };

    req.setRetryPolicy(new DefaultRetryPolicy(
            ASYNC_CONNECTION_NORMAL_TIMEOUT,
            DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
            0));
    VolleyRequestQueue.getInstance().addToRequestQueue(req);
}
 
开发者ID:Q115,项目名称:Goalie_Android,代码行数:24,代码来源:RESTUpvote.java

示例14: execute

import com.android.volley.toolbox.StringRequest; //导入依赖的package包/类
public void execute() {
    final String url = URL + "/register";
    isRegistering = true;
    StringRequest req = new StringRequest(Request.Method.POST, url, this, this) {
        @Override
        public Map<String, String> getHeaders() {
            return getDefaultHeaders();
        }

        @Override
        public byte[] getBody() throws AuthFailureError {
            Map<String, String> params = new HashMap<>();
            params.put("username", mUsername);
            params.put("device", "android");
            params.put("pushID", mPushID);
            return new JSONObject(params).toString().getBytes();
        }
    };

    req.setRetryPolicy(new DefaultRetryPolicy(
            ASYNC_CONNECTION_EXTENDED_TIMEOUT,
            DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
            0));
    VolleyRequestQueue.getInstance().addToRequestQueue(req);
}
 
开发者ID:Q115,项目名称:Goalie_Android,代码行数:26,代码来源:RESTRegister.java

示例15: SendRequest

import com.android.volley.toolbox.StringRequest; //导入依赖的package包/类
protected void SendRequest()
{
    StringRequest stringGetRequest = new StringRequest(Request.Method.GET, UserPref.getUserSearchURL(),
            new Response.Listener<String>(){
                @Override
                public void onResponse(String response)
                {
                    ParseJSON(response);
                }

            }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error)
        {
            Toast.makeText(UserSearchActivity.this,error.toString(),Toast.LENGTH_SHORT).show();
        }
    });
    requestQueue = Volley.newRequestQueue(this);
    requestQueue.add(stringGetRequest);

}
 
开发者ID:zhirunn,项目名称:CompassDemo,代码行数:22,代码来源:UserSearchActivity.java


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