Guest User

Untitled

a guest
Jul 20th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. @Override
  2. public void onBackPressed() {
  3. Intent data = new Intent();
  4. data.putExtra("Latitude", location.getLatitude() );
  5. data.putExtra("Longitude", location.getLongitude());
  6. setResult(RESULT_OK,data);
  7. super.onBackPressed();
  8.  
  9. }
  10. @Override
  11. protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  12. if(requestCode == request_Code){
  13. if(resultCode == RESULT_OK){
  14. Location location = new Location(provider);
  15. location.setLatitude(data.getDoubleExtra("Latitude", 0));
  16. location.setLongitude(data.getDoubleExtra("Longitude", 0));
  17. listener.onLocationChanged(location);
  18. }
  19. }
  20. super.onActivityResult(requestCode, resultCode, data);
  21. }
  22.  
  23. @Override
  24. protected void onResume() {
  25. super.onResume();
  26. // update your location here
  27. }
  28.  
  29. Take a flag in Activity A.
  30.  
  31. you are going A->B
  32. when you press back ,B finish();chack flag =true;and you will come back to A,
  33.  
  34. Now in A's onresume() method check for flag and if flag is true then update location
Add Comment
Please, Sign In to add comment