Note that there are some explanatory texts on larger screens.

plurals
  1. POjava.lang.NullPointerException when looking for Call Label?
    primarykey
    data
    text
    <p>Our app is getting a few error reports a week with this NullPointerException error on a onActivityResult(). We've tested it on many phones and have tried to fix our code but we are still getting reports from the Dev Console.</p> <p>Here is the error:</p> <pre><code> java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1001, result=-1, data=Intent { dat=content://com.android.contacts/data/612 flg=0x1 (has extras) }} to activity {com.package.app/com.package.app.PhoneLog}: java.lang.NullPointerException at android.app.ActivityThread.deliverResults(ActivityThread.java:2536) at android.app.ActivityThread.handleSendResult(ActivityThread.java:2578) at android.app.ActivityThread.access$2000(ActivityThread.java:117) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:965) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:123) at android.app.ActivityThread.main(ActivityThread.java:3691) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.NullPointerException at com.package.app.PhoneLog..onActivityResult(PhoneLog.java:555) at android.app.Activity.dispatchActivityResult(Activity.java:3934) at android.app.ActivityThread.deliverResults(ActivityThread.java:2532) ... 11 more </code></pre> <p>I think there error is coming from where we get the Call Label from the onActivityResult() below:</p> <pre><code> protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == RESULT_OK) { switch(requestCode) { case PICK_CONTACT: // handle the contact result Cursor c = getContact(data.getData()); if (c.moveToFirst()) { String name = c.getString(c.getColumnIndex("display_name")); String num = c.getString(c.getColumnIndex("data1")); typeLabel = c.getString(c.getColumnIndex("data2")); long l = c.getInt(c.getColumnIndex("contact_id")); c.getString(c.getColumnIndex("custom_ringtone")); //error is here Caused by: java.lang.NullPointerException //at PhoneLog.onActivityResult(PhoneLog.java:555) if(typeLabel.equals("1")) { typeLabel = "Home"; } else if(typeLabel.equals("2")) { typeLabel = "Mobile"; } else if(typeLabel.equals("3")) { typeLabel = "Work"; } else { typeLabel = ""; } callerName.setText(name); callerNum.setText(num); setChosenContactId(l); } break; } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload