-2

What could be the reason for the following stack trace :

java.lang.NullPointerException: storage == null --------- Stack trace --------- java.util.Arrays$ArrayList.(Arrays.java:38) java.util.Arrays.asList(Arrays.java:155) mypackage.MyJava$5.onClick(MyJava.java:479) android.view.View.performClick(View.java:5205) android.view.View$PerformClick.run(View.java:21164) android.os.Handler.handleCallback(Handler.java:743) android.os.Handler.dispatchMessage(Handler.java:95) android.os.Looper.loop(Looper.java:171) android.app.ActivityThread.main(ActivityThread.java:5417) java.lang.reflect.Method.invoke(Native Method) com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) ------------------------------- --------- Cause --------- -------------------------------

I tried assigning null to the items but this issue cannot be reproduced. Only few times this get reproduced i cant understand please help me..My code as follows

final String[] items= Global.currencycodes;
AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
                builder.setTitle("Currency");
                builder.setSingleChoiceItems(items, Arrays.asList(items).indexOf(((TextView) container.findViewById(R.id.currency)).getText()), new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int item) {
}
builder.create.show();

Here this exception from the line

builder.setSingleChoiceItems(items, Arrays.asList(items).indexOf(((TextView) container.findViewById(R.id.currency)).getText()), new DialogInterface.OnClickListener() {

Thanks in Advance.

Tas
  • 703
  • 6
  • 23

1 Answers1

0

Looks like Global.currencycodes is null, making items null. When a null object is passed to Arrays.asList(), it complains.

Eric Frechette
  • 138
  • 3
  • 6