标签: android-volley

带POST的GsonRequest

这是我正在使用的代码:

/**
 * Volley adapter for JSON requests that will be parsed into Java objects by Gson.
 */
public class GsonRequest<T> extends Request<T> {
    private final Gson gson = new GsonBuilder()
            .registerTypeAdapter(ClusterUnits.class, new ClusterUnitsDeserializer()).create();
    private final Class<T> clazz;
    private final Map<String, String> headers;
    private final Listener<T> listener;
    private JSONObject parameters = null;

    /**
     * Make a GET request and return a parsed object from JSON.
     *
     * @param url URL of the request to make
     * @param clazz Relevant class …
Run Code Online (Sandbox Code Playgroud)

android json gson android-volley

0
推荐指数
1
解决办法
6023
查看次数

毕加索是否支持图像磁盘缓存

在我使用Volley之前,我已经使用DiskLruCache [link] 和Volley将图像缓存在磁盘上.

现在我一直在使用正在使用Picasso的应用程序.

我想知道Picasso是否支持磁盘缓存.如果它支持我如何修复缓存大小.

使用磁盘缓存从远程加载图像时哪个有用?

android caching disk android-volley picasso

0
推荐指数
1
解决办法
3939
查看次数

自定义排球请求的NullPointerException

我试图使用自定义请求实现我的应用程序凌空,但我不断收到此错误,我无法修复.

这是错误

java.lang.NullPointerException: Attempt to invoke virtual method 'void co.app.al.app.volley.AppController.addToRequestQueue(com.android.volley.Request, java.lang.String)' on a null object reference
Run Code Online (Sandbox Code Playgroud)

这是AppController.java

public class AppController extends Application {

    public static final String TAG = AppController.class.getSimpleName();

    private RequestQueue mRequestQueue;
    private ImageLoader mImageLoader;
    LruBitmapCache mLruBitmapCache;

    private static AppController mInstance;

    @Override
    public void onCreate() {
        super.onCreate();
        mInstance = this;
    }

    public static synchronized AppController getInstance() {
        return mInstance;
    }

    public RequestQueue getRequestQueue() {
        if (mRequestQueue == null) {
            mRequestQueue = Volley.newRequestQueue(getApplicationContext());
        }

        return mRequestQueue;
    }

    public ImageLoader getImageLoader() …
Run Code Online (Sandbox Code Playgroud)

java android nullpointerexception android-volley

0
推荐指数
1
解决办法
9590
查看次数

Android凌空未知的构造函数

我正在尝试使用android排球.到目前为止,这是我的代码:

JsonObjectRequest getRequest = new JsonObjectRequest(Request.Method.GET, url, null,
        new Response.Listener<JSONObject>()
        {
            @Override
            public void onResponse(JSONObject response) {
                System.out.println(response);
            }
        },
        new Response.ErrorListener()
        {
            @Override
            public void onErrorResponse(VolleyError error) {
                System.out.println(error);
            }
        }
);
Run Code Online (Sandbox Code Playgroud)

这是关于齐射的我的进口:

import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.JsonObjectRequest;
import com.android.volley.toolbox.Volley;
Run Code Online (Sandbox Code Playgroud)

但是,这给了我"无法解决构造函数"错误.有任何想法吗?

android android-volley

0
推荐指数
1
解决办法
1106
查看次数

SecurityException:在棒棒糖上安装时权限被拒绝(缺少INTERNET权限?)

我收到以下错误:

NetworkDispatcher.run:未处理的异常java.lang.SecurityException:权限被拒绝(缺少INTERNET权限?)

导致此错误的原因是什么?如何解决?以下是我的AndroidManifest.xml档案.我正在使用Volley进行网络请求.

<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.rubad.abohaw">

    <uses-sdk
        android:minSdkVersion="9"
        android:targetSdkVersion="21"/>

    <user-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

    <application
        android:allowBackup="true"
        android:name=".MyApplication"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.rubad.abohaw.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
    </application>

</manifest>
Run Code Online (Sandbox Code Playgroud)

android permission-denied android-permissions android-volley android-5.0-lollipop

0
推荐指数
1
解决办法
818
查看次数

Android Volley - 没有来自StringRequest的回复

JSON使用Android Volley时我无法获得响应.没有错误也没有Succesfull响应see(Log.d("logr=",_response);).我使用StringRequest从Google Map API Android V2获取JSON文本.这是代码

private String urla = "https://maps.googleapis.com/maps/api/place/search/json?location=";
private String urlb = "&types=hotel&radius=500&sensor=false&key=YOUR_KEY";


   @Override //::LocationListener (Interface)
    public void onLocationChanged(Location location) {
        //Log.d(TAG, "Firing onLocationChanged..............................................");
        mCurrentLocation = location;
        CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(new LatLng(mCurrentLocation.getLatitude(), mCurrentLocation.getLongitude()), 13);
        googleMap.animateCamera(cameraUpdate);

        double x = location.getLatitude();
        double y = location.getLongitude();

        String request = urla+x+","+y+urlb;
        Log.d("log1=",request);
        StringRequest stringRequest = new StringRequest(Request.Method.GET, request,
                new Response.Listener<String>() {
                    @Override
                    public void onResponse(String _response) {

                        Log.d("logr=",_response);

                    }
                }, new Response.ErrorListener() {
            @Override …
Run Code Online (Sandbox Code Playgroud)

connection android json android-volley

0
推荐指数
1
解决办法
5006
查看次数

错误:com.android.volley.ParseError:org.json.JSONException:值<!DOCTYPE类型java.lang.String无法转换为JSONObject

JsonParse.Java试图从URL获取json数组对象,但它抛出了Parsing ERROR,
而CountriedBean是我的POJO类.
parse_json只有ListView,而parse_json_view有4个TextView

任何人都可以帮助我................

private List<CountriesBean> cntries= new ArrayList<CountriesBean>();
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.parse_json);

            RequestQueue queues = Volley.newRequestQueue(JsonParse.this);

            JsonObjectRequest myRequest = new JsonObjectRequest(Request.Method.GET,
                    "https://github.com/SaiNitesh/REST-Web-services/blob/master/RESTfulWS/json_file.json",
                    null,
                    new Response.Listener<JSONObject>() {
                        @Override
                        public void onResponse(JSONObject response) {
                            try{
                                Log.i("myCountries**", "response:" +response);
                            JSONArray countryItems = response.getJSONArray("countryItems");

                            Log.i("myTagx", "response:" +countryItems);

                                for(int i=0; i<countryItems.length();i++){
                                    JSONObject temp= countryItems.getJSONObject(i);

                                    String nm = temp.getString("nm");
                                    String cty = temp.getString("cty");
                                    String hse = temp.getString("hse");
                                    String yrs = temp.getString("yrs");

                                    cntries.add(new CountriesBean(nm, cty, hse, yrs));
                                }
                            } catch(JSONException e){ …
Run Code Online (Sandbox Code Playgroud)

android json android-volley android-json

0
推荐指数
1
解决办法
3132
查看次数

android高效的方式将图像上传到服务器

我正在寻找一种方法将图像从android上传到php服务器,目前我正在将图像编码为base64并发送它,但它太慢了,有没有更好的方法

我正在使用凌空作为网络客户端.

php java upload android android-volley

0
推荐指数
1
解决办法
2141
查看次数

第一次单击时,Android Edit文本onclicklistener无效

我写了使用onClick方法来将EditText数据加载到的函数RecycleView。单击时,将EditText所有数据加载到AlertBox,如果单击一个。然后RecycleView根据它加载所有数据。第一次没有显示,但是我再次单击EditText并选择数据,AlertBox然后在RecycleView

activity_day_plan.xml

<EditText
        android:id="@+id/txtline"
        android:layout_width="156dp"
        android:layout_height="33dp"
        android:clickable="true"
        android:focusable="false"
        android:focusableInTouchMode="false"

        android:layout_marginEnd="8dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="12dp"
        android:background="@drawable/input"
        android:ems="10"
        android:inputType="textPersonName"
        android:textAlignment="center"
        app:layout_constraintEnd_toStartOf="@+id/btnview"
        app:layout_constraintStart_toEndOf="@+id/txtfactoryname"
        app:layout_constraintTop_toBottomOf="@+id/txtfac" />
Run Code Online (Sandbox Code Playgroud)

主要活动

private EditText addline;

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_day_plan);

    addline=(EditText)findViewById(R.id.txtline);

    addline.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            getlist();
        }
    });
}

public void getlist()
{
    arrayList.clear();
    if(addfac.getText().equals(""))
    {
        Toast.makeText(DayPlanActivity.this,"Please Select Factory Code",Toast.LENGTH_SHORT).show();
    }
    else if(addline.getText().equals(""))
    {
        Toast.makeText(DayPlanActivity.this,"Please Select Line …
Run Code Online (Sandbox Code Playgroud)

android android-volley

0
推荐指数
3
解决办法
665
查看次数

处理片段中的空回收查看器

我正在尝试制作一个应用程序,在其中使用Recycle View和Volley从服务器获取数据,并且还使用了Navigation抽屉和片段,一切正常,但是当在recycle-view上没有数据时,我想显示一个通知,例如“没有数据!”我多次搜索互联网,但没有找到合适的解决方案,或者因为我完全是初学者,所以无法正确理解。

波纹管是我的Java文件

1.适配器

package com.eworld.myapplication;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.squareup.picasso.Picasso;

import java.util.List;

public class ExchangesAdapter extends RecyclerView.Adapter<ExchangesViewHolder> {

    private List<ExchangesSetterGetter>exchangeList;
    private Context context;

    public ExchangesAdapter(List<ExchangesSetterGetter> exchangeList, Context context) {
        this.exchangeList = exchangeList;
        this.context = context;
    }

    @NonNull
    @Override
    public ExchangesViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
        View view=LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.cardlayout,viewGroup,false);
        ExchangesViewHolder viewHolder=new ExchangesViewHolder(view);
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(@NonNull ExchangesViewHolder exchangesViewHolder, int i) {
        String status="";


        final ExchangesSetterGetter exchangesPosition=exchangeList.get(i);

            if (exchangesPosition.getStatus().equals("1")) …
Run Code Online (Sandbox Code Playgroud)

java android android-volley android-recyclerview

0
推荐指数
1
解决办法
87
查看次数