在Fragment中添加如下代码获取context:

// 获取context,防止getActivity出现NullPointerException
    private Context mContext;
    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        this.mContext = context;
    }

目前来看暂时解决问题

5-16更新
问题并没有解决, 采用新的方法, 自己写一个BaseFragment, 在其中定义context的监听方法

public abstract class ABaseFragment extends Fragment {

    protected IActivityEnabledListener aeListener;

    protected interface IActivityEnabledListener{
        void onActivityEnabled(FragmentActivity activity);
    }

    protected void getAvailableActivity(IActivityEnabledListener listener){
        if (getActivity() == null){
            aeListener = listener;

        } else {
            listener.onActivityEnabled(getActivity());
        }
    }

    @Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);

        if (aeListener != null){
            aeListener.onActivityEnabled((FragmentActivity) activity);
            aeListener = null;
        }
    }

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);

        if (aeListener != null){
            aeListener.onActivityEnabled((FragmentActivity) context);
            aeListener = null;
        }
    }
}

然后这样调用:

        getAvailableActivity(new IActivityEnabledListener() {
            @Override
            public void onActivityEnabled(FragmentActivity activity) {
                // listViewAdapter = new ListViewAdapter(activity.getApplicationContext());
                // 这里写需要context的方法
                Log.d(TAG, "onActivityEnabled: " + activity + " context: " + activity.getApplicationContext());
            }
        });

目前看来暂时解决问题。