HI, I've made an application B called by app A with the startActivityForResult method. When B try to return the result to A the application crashes and I get this error (by the way com.sistematica.carichispeciali.MobiWork is the application A, the one that calls B with startActivityForResult)
06-16 09:40:32.506: WARN/dalvikvm(744): threadid=3: thread exiting with uncaught exception (group=0x4001b390)
06-16 09:40:32.506: ERROR/AndroidRuntime(744): Uncaught handler: thread main exiting due to uncaught exception
06-16 09:40:32.526: ERROR/AndroidRuntime(744): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=Intent { (has extras) }} to activity {com.sistematica.carichispeciali/com.sistematica.carichispeciali.MobiWork}: java.lang.NullPointerException
06-16 09:40:32.526: ERROR/AndroidRuntime(744): at android.app.ActivityThread.deliverResults(ActivityThread.java:3504)
06-16 09:40:32.526: ERROR/AndroidRuntime(744): at android.app.ActivityThread.handleSendResult(ActivityThread.java:3546)
06-16 09:40:32.526: ERROR/AndroidRuntime(744): at android.app.ActivityThread.access$2700(ActivityThread.java:126)
06-16 09:40:32.526: ERROR/AndroidRuntime(744): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1962)
06-16 09:40:32.526: ERROR/AndroidRuntime(744): at android.os.Handler.dispatchMessage(Handler.java:99)
06-16 09:40:32.526: ERROR/AndroidRuntime(744): at android.os.Looper.loop(Looper.java:123)
06-16 09:40:32.526: ERROR/AndroidRuntime(744): at android.app.ActivityThread.main(ActivityThread.java:4595)
06-16 09:40:32.526: ERROR/AndroidRuntime(744): at java.lang.reflect.Method.invokeNative(Native Method)
06-16 09:40:32.526: ERROR/AndroidRuntime(744): at java.lang.reflect.Method.invoke(Method.java:521)
06-16 09:40:32.526: ERROR/AndroidRuntime(744): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
06-16 09:40:32.526: ERROR/AndroidRuntime(744): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
06-16 09:40:32.526: ERROR/AndroidRuntime(744): at dalvik.system.NativeStart.main(Native Method)
06-16 09:40:32.526: ERROR/AndroidRuntime(744): Caused by: java.lang.NullPointerException
06-16 09:40:32.526: ERROR/AndroidRuntime(744): at com.sistematica.carichispeciali.MobiWork.onActivityResult(MobiWork.java:96)
06-16 09:40:32.526: ERROR/AndroidRuntime(744): at android.app.Activity.dispatchActivityResult(Activity.java:3868)
06-16 09:40:32.526: ERROR/AndroidRuntime(744): at android.app.ActivityThread.deliverResults(ActivityThread.java:3500)
06-16 09:40:32.526: ERROR/AndroidRuntime(744): ... 11 more
this is how B returns the result
private void risultato(final String paper)
{
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setIcon(R.drawable.alt);
builder.setTitle("risultato");
builder.setMessage("è "+paper+" la targa?");
builder.setPositiveButton("si", new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface dialog, int which)
{
dialog.dismiss();
resultIntent = new Intent();
resultIntent.putExtra("1", paper);
setResult(Activity.RESULT_OK, resultIntent);
finish();
}
});
builder.setNegativeButton("no", new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface dialog, int which)
{
delRES();
}
});
builder.show();
};
and this is how A uses it (it should take the string returned and put it into an editText, never menaged to see if it really works since it crash before)
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch(requestCode) {
case (1) : {
if (resultCode == Activity.RESULT_OK) {
String newText = data.getStringExtra("1");
m_plateField.setText(newText);
}
break;
}
}
}