本文整理匯總了Java中com.android.volley.toolbox.Volley.newRequestQueue方法的典型用法代碼示例。如果您正苦於以下問題:Java Volley.newRequestQueue方法的具體用法?Java Volley.newRequestQueue怎麽用?Java Volley.newRequestQueue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.android.volley.toolbox.Volley
的用法示例。
在下文中一共展示了Volley.newRequestQueue方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onCreate
import com.android.volley.toolbox.Volley; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
if (queue == null)
queue = Volley.newRequestQueue(getApplicationContext());
prefs = getSharedPreferences("data", MODE_PRIVATE);
int gameno = prefs.getInt("gameno", -1);
if (gameno == -1)
return;
load();
}
示例2: onCreate
import com.android.volley.toolbox.Volley; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
iv_image = (ImageView) this.findViewById(R.id.iv_image);
bt_send = (Button) this.findViewById(R.id.bt_send);
nv_image = (NetworkImageView) this.findViewById(R.id.nv_image);
mQueue = Volley.newRequestQueue(getApplicationContext());
bt_send.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// UseStringRequest();
UseJsonRequest();
// UseImageRequest();
// UseImageLoader();
// UseNetworkImageView();
}
});
}
示例3: getRequestQueue
import com.android.volley.toolbox.Volley; //導入方法依賴的package包/類
public RequestQueue getRequestQueue() {
if (mRequestQueue == null) {
// getApplicationContext() is key, it keeps you from leaking the
// Activity or BroadcastReceiver if someone passes one in.
mRequestQueue = Volley.newRequestQueue(mCtx.getApplicationContext());
}
return mRequestQueue;
}
示例4: SetupHelper
import com.android.volley.toolbox.Volley; //導入方法依賴的package包/類
public SetupHelper(Context context){
this.context = context;
username = "";
password = "";
email = "";
serverURL = "";
// Initiate Volley Request Queue
queue = Volley.newRequestQueue(this.context);
}
示例5: getRequestQueue
import com.android.volley.toolbox.Volley; //導入方法依賴的package包/類
public RequestQueue getRequestQueue()
{
if(requestQueue==null)
{
requestQueue= Volley.newRequestQueue(mContext);
}
return requestQueue;
}
示例6: setUp
import com.android.volley.toolbox.Volley; //導入方法依賴的package包/類
@Before
public void setUp() throws IOException {
MockitoAnnotations.initMocks(this);
waitForResponseLatch = new CountDownLatch(1);
doAnswer(new CountDown()).when(callback).onDataReady(any(InputStream.class));
doAnswer(new CountDown()).when(callback).onLoadFailed(any(Exception.class));
requestQueue = Volley.newRequestQueue(RuntimeEnvironment.application);
mockWebServer = new MockWebServer();
mockWebServer.start();
streamCaptor = ArgumentCaptor.forClass(InputStream.class);
}
示例7: SendRequest
import com.android.volley.toolbox.Volley; //導入方法依賴的package包/類
protected void SendRequest()
{
SharedPreferences sharedPreferences = getSharedPreferences(UserPref.getSharedPrefName(), Context.MODE_PRIVATE);
final String ID = sharedPreferences.getString(UserPref.getKeyUserId(),"Null");
StringRequest stringGetRequest = new StringRequest(Request.Method.POST, UserPref.getBrokerloansUrl(),
new Response.Listener<String>() {
@Override
public void onResponse(String response)
{
ParseJSON(response);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error)
{
Toast.makeText(BrokerLoanActivity.this,error.toString(),Toast.LENGTH_SHORT).show();
}
}){ @Override
protected Map<String, String> getParams() throws AuthFailureError {
Map<String, String> params = new HashMap<>();
params.put(UserPref.getKeyUserId(), ID);
return params;
}} ;
requestQueue = Volley.newRequestQueue(this);
requestQueue.add(stringGetRequest);
}
示例8: SendRequest
import com.android.volley.toolbox.Volley; //導入方法依賴的package包/類
protected void SendRequest()
{
StringRequest stringGetRequest = new StringRequest(Request.Method.POST, "https://greatnorthcap.000webhostapp.com/PHP/statusloans.php",
new Response.Listener<String>() {
@Override
public void onResponse(String response)
{
ParseJSON(response);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error)
{
Toast.makeText(LoanStatusActivity.this,error.toString(),Toast.LENGTH_SHORT).show();
}
}){ @Override
protected Map<String, String> getParams() throws AuthFailureError {
Map<String, String> params = new HashMap<>();
params.put("id", ID);
return params;
}} ;
requestQueue = Volley.newRequestQueue(this);
requestQueue.add(stringGetRequest);
}
示例9: getRequestQueue
import com.android.volley.toolbox.Volley; //導入方法依賴的package包/類
public RequestQueue getRequestQueue() {
if (mRequestQueue == null) {
mRequestQueue = Volley.newRequestQueue(getApplicationContext());
}
return mRequestQueue;
}
示例10: getRequestQueue
import com.android.volley.toolbox.Volley; //導入方法依賴的package包/類
public synchronized static RequestQueue getRequestQueue() {
if (requestQueue == null) {
requestQueue = Volley.newRequestQueue(appInstance);
}
Log.d("TEST", "entering getRequestQueue");
Log.d("TEST", "Application instance: " + appInstance);
Log.d("TEST", "requestQueue instance: " + requestQueue);
return requestQueue;
}
示例11: onAfterViews
import com.android.volley.toolbox.Volley; //導入方法依賴的package包/類
@Override
public void onAfterViews() {
initToolbar();
userInfoSp = MyApplication_.getInstance().getUserInfoSp();
mRequestQueue = Volley.newRequestQueue(this);
mListPop = new ListPopupWindow(this);
onBackgrounds();
initView();
}
示例12: getRequestQueue
import com.android.volley.toolbox.Volley; //導入方法依賴的package包/類
public RequestQueue getRequestQueue() {
if (mRequestQueue == null) {
mRequestQueue = Volley.newRequestQueue(mCtx.getApplicationContext());
}
return mRequestQueue;
}
示例13: onCreate
import com.android.volley.toolbox.Volley; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestQueue= Volley.newRequestQueue(this);
imageLoader=new ImageLoader(requestQueue,new Fdv_ImageCache());
}
示例14: uploadBankStatement
import com.android.volley.toolbox.Volley; //導入方法依賴的package包/類
private void uploadBankStatement() {
//final SharedPreferences sharedPreferences = getSharedPreferences(UserPref.getSharedPrefName(), Context.MODE_PRIVATE);
StringRequest stringRequest = new StringRequest(Request.Method.POST, UserPref.getImageuploadUrl(),
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
Toast.makeText(UploadImageActivity.this, response, Toast.LENGTH_LONG).show();
finish();
Intent intent = new Intent(UploadImageActivity.this, UploadLoanImagesActivity.class);
//startActivity(new Intent(UploadImageActivity.this, UploadLoanImagesActivity.class));
intent.setFlags(FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
finish();
//an Intent should be used to change pages after the user successfully uploaded their image.
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError volleyError) {
Toast.makeText(UploadImageActivity.this, "Please Select An Image.", Toast.LENGTH_LONG).show();
//String type = sharedPreferences.getString(UserPref.getUploadtypeSharedPref(), "Not Available");
//Toast.makeText(UploadImageActivity.this, type, Toast.LENGTH_LONG).show();
//Toast.makeText(UploadImageActivity.this, volleyError.toString(), Toast.LENGTH_LONG).show();
}
}){
@Override
protected Map<String, String> getParams() throws AuthFailureError {
SharedPreferences sharedPreferences = getSharedPreferences(UserPref.getSharedPrefName(), Context.MODE_PRIVATE);
String image = getStringImage(bitmap);
String type = sharedPreferences.getString(UserPref.getUploadtypeSharedPref(), "Not Available");
String loanid = sharedPreferences.getString(UserPref.getSearchedloanidSharedPref(), "Not Available");
//Toast.makeText(UploadImageActivity.this, image.toString(), Toast.LENGTH_LONG).show();
Map<String,String> params = new Hashtable<>();
params.put(KEY_IMAGE, image);
params.put(KEY_TYPE, type);
params.put(KEY_LOANID, loanid);
return params;
}
};
RequestQueue requestQueue = Volley.newRequestQueue(this);
requestQueue.add(stringRequest);
}
示例15: getData
import com.android.volley.toolbox.Volley; //導入方法依賴的package包/類
private void getData(){
String url="http://crcrcry.com.cn/reward?token="+LocalStorage.getItem(getActivity(),"token");
if(start!=null){
url+="&start="+start;
}
RequestQueue mqueue= Volley.newRequestQueue(getActivity());
if(isLoading) return;
isLoading=true;
final int psize=10; //每次請求的數據數量
//可選傳入start,end
JsonObjectRequest jsonRequest=new JsonObjectRequest
(Request.Method.GET, url+"&p="+page+"&psize="+psize, null, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
try {
JSONObject jsonData=response.getJSONObject("data");
if(response.getInt("code")==0){
LocalStorage.setItem(getActivity(),"token",jsonData.getString("token"));
JSONArray jsonArray=jsonData.getJSONArray("rewardList");
System.out.println(jsonArray);
ArrayList<RewardModel> newList= ( ArrayList<RewardModel> ) JSONArr2List(jsonArray);
if(newList.size()<psize){
loadComplete();
}
else if(isEnd){
isEnd=false;
listView.addFooterView(loadmoreView);
}
dataList.addAll(newList);
// set adapter
if(adapter==null) {
adapter = new RewardListAdapter(getActivity(), dataList);
listView.setAdapter(adapter);
}
else{
adapter.updateView(dataList);
}
page++;
}
else{
Toast.makeText(getActivity(),response.getString("msg"),Toast.LENGTH_SHORT).show();
}
} catch (JSONException e) {
e.printStackTrace();
}
isLoading=false;
refreshLayout.setRefreshing(false);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
String msg="";
if(error.networkResponse!=null && error.networkResponse.statusCode==401){
msg="Invalid token";
}
else {
msg="Network error";
}
Toast.makeText(getActivity(),msg,Toast.LENGTH_SHORT).show();
isLoading=false;
refreshLayout.setRefreshing(false);
}
});
mqueue.add(jsonRequest);
}