Hi guys i am getting the following exception
java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.Resources$Theme android.content.Context.getTheme()' on a null object reference --------- Stack trace --------- android.app.AlertDialog.resolveDialogTheme(AlertDialog.java:222) android.app.AlertDialog$Builder.(AlertDialog.java:452) com.skyvin.numr.scanreceipt.ReceiptDetail$convertCurrency.onPostExecute(ReceiptDetail.java:2309) com.skyvin.numr.scanreceipt.ReceiptDetail$convertCurrency.onPostExecute(ReceiptDetail.java:2199) android.os.AsyncTask.finish(AsyncTask.java:651) android.os.AsyncTask.access$500(AsyncTask.java:180) android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:668) android.os.Handler.dispatchMessage(Handler.java:102) android.os.Looper.loop(Looper.java:158) android.app.ActivityThread.main(ActivityThread.java:7229) java.lang.reflect.Method.invoke(Native Method) com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) ------------------------------- --------- Cause --------- -------------------------------

My code is as follows

AlertDialog.Builder builder;
LayoutInflater inflater = (LayoutInflater)
mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
final View layout = inflater.inflate(R.layout.currencyconvert,null);
builder = new AlertDialog.Builder(ReceiptDetail.this.getActivity());
                    builder.setTitle("Exchange Rate");
                    builder.setView(layout)
                    builder.create.show();

inthis code i am getting exception from builder.setView(layout)

What would be the reason

For this I have to read priors at https://www.google.com/search?q=lertDialog.Builder&ie=utf-8&oe=utf-8#q=alertDialog.Builder+virtual+

Since you shared just a sliver of what your app holds my bet is some activity is not present at the time of the call. So it nulls and crashes.
http://stackoverflow.com/questions/28395271/android-app-crashing-when-it-reaches-alertdialog-builder-using-post-method kicked it around the most IMO.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.