Basically I am calling a function of fragment from Main Activity. And the function goal is to send api to server get data back from parser class and
set it to Fragment RecyclerView.
But its giving me an error and pointing in parser class on progressDialog = new ProgressDialog(this.context)
; Error is below.
java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.Resources$Theme android.content.Context.getTheme()' on a null object reference
Here is my code in main activity which is calling my function from fragment.
if(adapterPosition==0) {
SecondFragment secondFragment=new SecondFragment();
secondFragment.SearchCategoresFunction(text);
}
Here is my function in Fragment:
public void SearchCategoresFunction(final String searchTxt){
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
mparser = new SecondParseDataClass(getContext());
mparser.setOnDataRetrievalCallback(new OnDataRetrievalCallback() {
@Override
public void onDataRetrieval(ArrayList<DataStored> dataSet) {
dataStoredArrayList.addAll(dataSet);
myRecyclerAdapter.notifyDataSetChanged();
}
});
mparser.execute("http://192.168.3.10/fetchtext.php", "2",searchTxt);
}
}, 0);
}
Please guide me how can I remove this error.