java.lang.NullPointerException in json error

31 views Asked by At

At First run everthing is good it's running with no error but when i try to refresh it using swiperefreshlayout boom! it crash :( i got this error.

 java.lang.NullPointerException
        at parse.FeedDataParser.getFeed(FeedDataParser.java:25)
        at better.business.solution.feedssample.SampleGraph$1.onCompleted(SampleGraph.java:57)
        at com.facebook.GraphRequest$5.run(GraphRequest.java:1243)
        at android.os.Handler.handleCallback(Handler.java:615)
        at android.os.Handler.dispatchMessage(Handler.java:92)
        at android.os.Looper.loop(Looper.java:137)
        at android.app.ActivityThread.main(ActivityThread.java:4745)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:511)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
        at dalvik.system.NativeStart.main(Native Method)

this is my code in FeedDataParser

    public List<ResultFeed> getFeed(){

    try {
        List<ResultFeed> result = new ArrayList<ResultFeed>();
        JSONObject jsonObject = mFeedJson.getJSONObject("feed");
        JSONArray jsonArray = jsonObject.getJSONArray("data");
        for(int ctr=0; ctr<jsonArray.length();ctr++){
             ResultFeed resultFeed = new ResultFeed(jsonArray.getJSONObject(ctr));
             result.add(resultFeed);
        }
        return result;


    } catch (JSONException e) {
        e.printStackTrace();
    }
    return null;
}

and my asynctask which call everytime i refresh my app.

    private List<ResultFeed> feedItemList;
    private MyAdapter myAdapter;
    private SwipeRefreshLayout mSwipeRefreshLayout;
   public InitializeApplicationsTask(Context context,AccessToken accessToken,OnDataFullFeedListener dataFullFeedListener,List<ResultFeed> feedItemList,MyAdapter myAdapter,RecyclerView mRecyclerView,SwipeRefreshLayout mSwipeRefreshLayout) {

        this.feedItemList = feedItemList;
        this.myAdapter = myAdapter;
        this.mSwipeRefreshLayout = mSwipeRefreshLayout;

        GraphRequestFeeds graphRequestFeeds = new GraphRequestFeeds(dataFullFeedListener,context);
        graphRequestFeeds.resultInBatchReq(accessToken);

        Log.e("constructor",""+accessToken);

    }

    @Override
    protected void onPreExecute() {

        super.onPreExecute();
        Log.e("onPre", "jac");
    }

    @Override
    protected List<ResultFeed> doInBackground(Void... params) {


        Log.e("doinBack", "jac");
        Log.e("feeditemlist1",""+feedItemList);
        return null;
    }

    @Override
    protected void onPostExecute(List<ResultFeed> resultFeeds) {
        super.onPostExecute(resultFeeds);
           mSwipeRefreshLayout.setRefreshing(false);

    }

Plsss help me :((((

0

There are 0 answers