1

I have an activity that launches another one using startActivityForResult. This step is ok. Then the second activity has a map and when a button is clicked the geopoint coordinates are passed to a bundle that is used on first activity to fullfil an EditText. The function onActivityResult is runned until the end and then the program crashes and appears a message with "Source not found" on screen.

This is the function on mapActivity:

public void ConfirmLoc(View v){
    double lat = loc.getLatitudeE6()/1E6;
    double lng = loc.getLongitudeE6()/1E6;
    Intent ievloc = new Intent();
    Bundle bevloc = new Bundle();
    bevloc.putDouble("latitude",lat);
    bevloc.putDouble("longitude",lng);
    ievloc.putExtras(bevloc);
    setResult(RESULT_OK,ievloc);
    finish();
}

And this is the onActivityResult on first Activity:

protected void onActivityResult(int requestCode, int resultCode, Intent data){
    if(requestCode==1){
        if(resultCode==RESULT_OK){
            EditText loc= (EditText) findViewById(R.id.LocalizacaoEvento);
            bevloc = data.getExtras();
            if(bevloc!=null){
                String latitud = String.valueOf(bevloc.getDouble("latitude"));
                String longitud = String.valueOf(bevloc.getDouble("longitude"));
                loc.setText(latitud+" , "+longitud,TextView.BufferType.EDITABLE);

            }
        }
        else if(resultCode==RESULT_CANCELED){

        }
    }
}

Can anyone help? thanks

1 Answers1

1

You need to add the @Override line on top of your onActivityResult method. When you do this, you will also be adding the following line as the first line of the method:

super.onActivityResult(requestCode, resultCode, data); 

Also ensure that your compiler settings is 1.6 and not 1.5 as by default in Eclipse.

SalGad
  • 2,991
  • 2
  • 18
  • 25
  • Also did that and the problem persists. I will put all activity code. –  Dec 21 '12 at 09:50
  • Forgot to mention...The calling activity extends a FragmentActivity. –  Dec 21 '12 at 09:55
  • If you set a breakpoint in the OnActivityResult method, does it break there when you finish() the map activity? Run it in debug mode and see (in Eclipse it's the tiny bug button next to the Run button) – SalGad Dec 21 '12 at 10:01
  • By adding further breakpoints, you should be able to figure out which line causes the crash. Can you find this line? – SalGad Dec 21 '12 at 10:14
  • It does the finish() correctly and breaks just after run the onActivityResult method. I can see the coordinates on text box. –  Dec 21 '12 at 10:23
  • It says just is: "source not found". These are the last logcat lines:12-21 10:26:57.028: E/AndroidRuntime(21424): Uncaught handler: thread main exiting due to uncaught exception 12-21 10:26:57.148: E/AndroidRuntime(21424): android.app.SuperNotCalledException: Activity {com.example.su/com.example.su.LocMap} did not call through to super.onStop() 12-21 10:26:57.148: E/AndroidRuntime(21424): at android.app.Activity.performStop(Activity.java:3804) –  Dec 21 '12 at 10:51
  • 12-21 10:26:57.148: E/AndroidRuntime(21424): at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3423) 12-21 10:26:57.148: E/AndroidRuntime(21424): at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3494) 12-21 10:26:57.148: E/AndroidRuntime(21424): at android.app.ActivityThread.access$2800(ActivityThread.java:123) 12-21 10:26:57.148: E/AndroidRuntime(21424): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1903) 12-21 10:26:57.148: E/AndroidRuntime(21424): at android.os.Handler.dispatchMessage(Handler.java:99) –  Dec 21 '12 at 10:52
  • 12-21 10:26:57.148: E/AndroidRuntime(21424): at android.os.Looper.loop(Looper.java:123) 12-21 10:26:57.148: E/AndroidRuntime(21424): at android.app.ActivityThread.main(ActivityThread.java:4370) 12-21 10:26:57.148: E/AndroidRuntime(21424): at java.lang.reflect.Method.invokeNative(Native Method) 12-21 10:26:57.148: E/AndroidRuntime(21424): at java.lang.reflect.Method.invoke(Method.java:521) 12-21 10:26:57.148: E/AndroidRuntime(21424): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) –  Dec 21 '12 at 10:52
  • 12-21 10:26:57.148: E/AndroidRuntime(21424): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 12-21 10:26:57.148: E/AndroidRuntime(21424): at dalvik.system.NativeStart.main(Native Method) 12-21 10:26:57.358: E/SemcCheckin(21424): Get crash dump level : java.io.FileNotFoundException: /data/semc-checkin/crashdump 12-21 10:26:57.478: I/dalvikvm(21424): threadid=7: reacting to signal 3 12-21 10:26:57.508: I/dalvikvm(21424): Wrote stack trace to '/data/anr/traces.txt' –  Dec 21 '12 at 10:53
  • Can you add another method: @Override public void onStop() { super.onStop(); } to both activities? – SalGad Dec 21 '12 at 11:06