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


Java VolleyError类代码示例

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


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

示例1: imageUpload

import com.android.volley.error.VolleyError; //导入依赖的package包/类
private void imageUpload(final String imagePath) {

        SimpleMultiPartRequest smr = new SimpleMultiPartRequest(Request.Method.POST, BASE_URL,
                new Response.Listener<String>() {
                    @Override
                    public void onResponse(String response) {
                        Log.d("Response", response);
                        try {
                            JSONObject jObj = new JSONObject(response);
                            String message = jObj.getString("message");

                            Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG).show();

                        } catch (JSONException e) {
                            // JSON error
                            e.printStackTrace();
                            Toast.makeText(getApplicationContext(), "Json error: " + e.getMessage(), Toast.LENGTH_LONG).show();
                        }
                    }
                }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                Toast.makeText(getApplicationContext(), error.getMessage(), Toast.LENGTH_LONG).show();
            }
        });

        smr.addFile("image", imagePath);
        MyApplication.getInstance().addToRequestQueue(smr);

    }
 
开发者ID:huluhive,项目名称:android-volley-file-upload,代码行数:31,代码来源:MainActivity.java

示例2: update

import com.android.volley.error.VolleyError; //导入依赖的package包/类
@Override
public void update() {
    JsonObjectRequest jsonObjReq = new JsonObjectRequest(Request.Method.GET,
            JSON_ALL_DISRUPT, null,
            new Response.Listener<JSONObject>() {

                @Override
                public void onResponse(final JSONObject response) {
                    new BackgroundTask().execute(response);
                }
            }, new Response.ErrorListener() {

        @Override
        public void onErrorResponse(VolleyError error) {
            Log.d(TAG, "Error: " + error.getMessage());
        }
    });
    VolleyApp.getInstance(context).addToRequestQueue(jsonObjReq);
}
 
开发者ID:flyingrub,项目名称:TamTime,代码行数:20,代码来源:DisruptEventHandler.java

示例3: update

import com.android.volley.error.VolleyError; //导入依赖的package包/类
@Override
public void update() {
    JsonObjectRequest jsonObjReq = new JsonObjectRequest(Request.Method.GET,
            JSON_REALTIME, null,
            new Response.Listener<JSONObject>() {

                @Override
                public void onResponse(JSONObject response) {
                    setRealTimes(response);
                }
            }, new Response.ErrorListener() {

        @Override
        public void onErrorResponse(VolleyError error) {
            Log.d(TAG, "Error: " + error.getMessage());
        }
    });
    VolleyApp.getInstance(context).addToRequestQueue(jsonObjReq);
}
 
开发者ID:flyingrub,项目名称:TamTime,代码行数:20,代码来源:RealTimes.java

示例4: update

import com.android.volley.error.VolleyError; //导入依赖的package包/类
@Override
public void update() { // Theoric times
    JsonObjectRequest jsonObjReq = new JsonObjectRequest(Request.Method.GET,
            JSON_THEOTIME, null,
            new Response.Listener<JSONObject>() {

                @Override
                public void onResponse(JSONObject response) {
                    setTheoTimes(response);
                }
            }, new Response.ErrorListener() {

        @Override
        public void onErrorResponse(VolleyError error) {
            Log.d(TAG, "Error: " + error.getMessage());
        }
    });
    VolleyApp.getInstance(context).addToRequestQueue(jsonObjReq);
}
 
开发者ID:flyingrub,项目名称:TamTime,代码行数:20,代码来源:TheoricTimes.java

示例5: update

import com.android.volley.error.VolleyError; //导入依赖的package包/类
@Override
public void update() {
    JsonObjectRequest jsonObjReq = new JsonObjectRequest(Request.Method.GET,
            JSON_REPORT, null,
            new Response.Listener<JSONObject>() {

                @Override
                public void onResponse(JSONObject response) {
                    setReport(response);
                }
            }, new Response.ErrorListener() {

        @Override
        public void onErrorResponse(VolleyError error) {
            Log.d(TAG, "Error: " + error.getMessage());
        }
    });
    VolleyApp.getInstance(context).addToRequestQueue(jsonObjReq);
}
 
开发者ID:flyingrub,项目名称:TamTime,代码行数:20,代码来源:ReportEvent.java

示例6: onTextChange

import com.android.volley.error.VolleyError; //导入依赖的package包/类
/**
 * (non-doc)
 */
private void onTextChange(String query) {
    mClient.getRequestQueue().cancelAll("SEARCH");
    mClient.searchTrack(query).setListener(new Response.Listener<Page<Track>>() {
        @Override
        public void onResponse(Page<Track> tracks) {
            final List<Track> items = tracks.getItems();
            for (Track item : items) {
                Log.d("Track", item.getArtist(0).getName() + " - " + item.getName());
            }
        }
    }).setErrorListener(new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError volleyError) {
            volleyError.printStackTrace();
        }
    }).setLimit(25).setTag("SEARCH").build();
}
 
开发者ID:SiegenthalerSolutions,项目名称:spotify-web-api-android,代码行数:21,代码来源:ExampleActivity.java

示例7: createBlurImageListener

import com.android.volley.error.VolleyError; //导入依赖的package包/类
/**
 * Gets a Blurred bitmap for the imageView suggested.
 *
 * @param view
 * @return
 */
public static ImageLoader.ImageListener createBlurImageListener(final ImageView view) {
    return new ImageLoader.ImageListener() {
        @Override
        public void onResponse(ImageLoader.ImageContainer response, boolean isImmediate) {
            BitmapDrawable bd = response.getBitmap();
            if (bd != null) {
                ImageBlurTask blur = new ImageBlurTask() {
                    @Override
                    protected void onPostExecute(Bitmap bitmap) {
                        super.onPostExecute(bitmap);
                        view.setImageBitmap(bitmap);
                    }
                };
                blur.execute(bd.getBitmap());
            }
        }

        @Override
        public void onErrorResponse(VolleyError error) {

        }
    };
}
 
开发者ID:adfleshner,项目名称:USADiving_Helix,代码行数:30,代码来源:VolleyUtils.java

示例8: startDownloadAudio

import com.android.volley.error.VolleyError; //导入依赖的package包/类
public void startDownloadAudio(final String audioUrl, final long playToken, final DownloadAudioCallback callback) {
    DownloadRequest request = new DownloadRequest(audioUrl, DEVolley.getInstance().getTempAudioDownloadFile().getPath(),
            new Response.Listener<String>() {
                @Override
                public void onResponse(String response) {
                    callback.onSuccess(audioUrl, playToken);
                }
            }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            callback.onFail(audioUrl, playToken);
        }
    });
    request.setRetryPolicy(DEVolley.getInstance().getDefaultRetryPolicy(2));
    request.setTag("fetchSentenceAudio");
    DEVolley.getInstance().getRequestQueue().add(request);
}
 
开发者ID:enuoCM,项目名称:DE-MVP-Clean,代码行数:18,代码来源:SentenceDataRepository.java

示例9: sendReport

import com.android.volley.error.VolleyError; //导入依赖的package包/类
public void sendReport(final Context context, final Report report) {
    Map<String,String> params = new HashMap<String, String>();
    params.put("our_id", report.getStop().getOurId() + "");
    params.put("type", report.getType().getValue() + "");
    params.put("msg", report.getMessage());

    StringRequest sr = new StringRequest(
            Request.Method.POST,
            POST_REPORT,
            new Response.Listener<String>() {
                @Override
                public void onResponse(String response) {
                    Integer result = Integer.parseInt(response);
                    Log.d(TAG, "REPONSE:" + response + "|");
                    Toast.makeText(context, context.getResources().getStringArray(R.array.post_status)[result], Toast.LENGTH_SHORT).show();
                    update();
                }
            },
            new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    Log.d(TAG, "Error: " + error.getMessage());
                }
            }) {
    };
    sr.setParams(params);
    VolleyApp.getInstance(context).addToRequestQueue(sr);
}
 
开发者ID:flyingrub,项目名称:TamTime,代码行数:29,代码来源:ReportEvent.java

示例10: confirmReport

import com.android.volley.error.VolleyError; //导入依赖的package包/类
public void confirmReport(final Context context, final int reportId) {
    Map<String,String> params = new HashMap<String, String>();
    params.put("report_id", reportId + "");

    StringRequest sr = new StringRequest(
            Request.Method.POST,
            CONFIRM_REPORT,
            new Response.Listener<String>() {
                @Override
                public void onResponse(String response) {
                    Integer result = Integer.parseInt(response);
                    Log.d(TAG, "REPONSE:" + response + "|");
                    Toast.makeText(context, context.getResources().getStringArray(R.array.confirm_status)[result], Toast.LENGTH_SHORT).show();
                    update();
                }
            },
            new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    Log.d(TAG, "Error: " + error.getMessage());
                }
            }) {
    };
    sr.setParams(params);
    VolleyApp.getInstance(context).addToRequestQueue(sr);
}
 
开发者ID:flyingrub,项目名称:TamTime,代码行数:27,代码来源:ReportEvent.java

示例11: onCreate

import com.android.volley.error.VolleyError; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void onCreate(Bundle instance) {
    super.onCreate(instance);
    setContentView(R.layout.activity_main);

    final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    mClient = new ClientRestAPI(Volley.newRequestQueue(getApplicationContext()));

    findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Log.d("XXX", "Click");
            mClient.getAlbum("2dIGnmEIy1WZIcZCFSj6i8").setListener(new Response.Listener<Album>() {
                @Override
                public void onResponse(Album o) {
                    Log.d("XXX", o.getName());
                }
            }).setErrorListener(new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError volleyError) {
                    Log.d("XXX", "ERROR:" + volleyError.getMessage());
                }
            }).build();
        }
    });
}
 
开发者ID:SiegenthalerSolutions,项目名称:spotify-web-api-android,代码行数:32,代码来源:ExampleActivity.java

示例12: createErrorListener

import com.android.volley.error.VolleyError; //导入依赖的package包/类
/**
 * Generic Error Listener
 */
public static Response.ErrorListener createErrorListener() {
    return new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
        }
    };
}
 
开发者ID:adfleshner,项目名称:USADiving_Helix,代码行数:11,代码来源:VolleyUtils.java

示例13: run

import com.android.volley.error.VolleyError; //导入依赖的package包/类
@Override
public void run() {
    Location l = null;
    if (ContextCompat.checkSelfPermission(getApplicationContext(),
            Manifest.permission.ACCESS_COARSE_LOCATION)
            == PackageManager.PERMISSION_GRANTED) {
            //l = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
    }else{
        ActivityCompat.requestPermissions((Activity)MainActivity.getContext(),
                new String[]{Manifest.permission.ACCESS_COARSE_LOCATION},
                10);
    }
    //Create a post request
    final Location finalL = l;
    StringRequest request = new StringRequest(Request.Method.POST,
            "http://api.openpokemap.pw/c", new Response.Listener<String>() {
        @Override
        public void onResponse(String response) {
            //Find location

            //Handle response
            Log.w("Json", response);
            JsonParser parser = new JsonParser();
            JsonArray pokemons = parser.parse(response).getAsJsonObject()
                    .getAsJsonArray("MapObjects");

            for (int i=0; i<pokemons.size();i++){
                JsonObject o = pokemons.get(i).getAsJsonObject();
                int id = o.get("PokemonId").getAsInt();
                String uuid = o.get("Id").getAsString();
                if(RarePokemons.contains(id)){
                    Log.i("P", "Rare pokemon found!");

                    Intent notificationIntent = new Intent(getApplicationContext(), MainActivity.class);

                    PendingIntent intent = PendingIntent.getActivity(getApplicationContext(), 0,
                            notificationIntent, 0);

                    String name = names.get(id);

                    NotificationCompat.Builder mBuilder =
                            new NotificationCompat.Builder(getApplicationContext())
                                    .setSmallIcon(R.drawable.map)
                                    .setContentTitle("A wild " + name + " is nearby!")
                                    .setContentIntent(intent)
                                    .setVibrate(new long[] { 1000, 1000, 1000, 1000, 1000 })
                                    .setLights(Color.MAGENTA, 3000, 3000);

                    mNotifyMgr.notify(i, mBuilder.build());
                }
            }
        }

    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            Log.e("notifications", error.getStackTrace().toString());
            return;
        }
    }){
        @Override
        protected Map<String,String> getParams() {
            Map<String,String> params = new HashMap<String, String>();
            String lat = Double.toString(0);
            String lng = Double.toString(0);
            params.put("lat", lat);
            params.put("lng", lng);
            params.put("p", "true");
            return params;
        }
    };
    queue.add(request);

    //Re run this after 5 minutes
    h.postDelayed(notificationRunnable, 1*60*1000);
}
 
开发者ID:pogointel,项目名称:openmap-client-android,代码行数:77,代码来源:Notifications.java


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