Questions tagged [onactivityresult]

Called when an activity you launched exits, giving you the requestCode you started it with, the resultCode it returned, and any additional data from it. The resultCode will be RESULT_CANCELED if the activity explicitly returned that, didn't return any result, or crashed during its operation.

Called when an activity you launched exits, giving you the requestCode you started it with, the resultCode it returned, and any additional data from it. The resultCode will be RESULT_CANCELED if the activity explicitly returned that, didn't return any result, or crashed during its operation.

You will receive this call immediately before onResume() when your activity is re-starting.

Click Here for Google Android Documentation

990 questions
524
votes
30 answers

OnActivityResult method is deprecated, what is the alternative?

I recently discovered that onActivityResult is deprecated. What should we do to handle it? Any alternative introduced for that?
352
votes
6 answers

Wrong requestCode in onActivityResult

I'm starting a new Activity from my Fragment with startActivityForResult(intent, 1); and want to handle the result in the Fragment's parent Activity: @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { …
Dimanoid
  • 6,999
  • 4
  • 40
  • 55
162
votes
5 answers

Android: how to make an activity return results to the activity which calls it?

I have a Location activity that can be called from many activities, such as Sign up and Order. In the Location activity the user enters his location, so the activity Location will return this new location to that activity which called it. So when…
user user
  • 2,122
  • 6
  • 19
  • 24
65
votes
8 answers

How to replace startActivityForResult with Activity Result APIs?

I have a main activity which serves as an entry point to call different activities, depending on condition. Among others, I use Firebase Auth to manage user sign in: startActivityForResult( …
Neoh
  • 15,906
  • 14
  • 66
  • 78
39
votes
5 answers

OnActivityResult sometimes not called after ACTION_GET_CONTENT intent

I'm working on an image editing Android application. In one of my activities I call an intent to pick an image from the gallery in onCreate() like this: Intent intent = new…
WPMed
  • 1,414
  • 1
  • 13
  • 25
36
votes
1 answer

Error: onActivityResult overrides nothing

I am programming a speech recognition app in Kotlin for Android. class MainActivity : AppCompatActivity() { public override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) …
Marcel Sonderegger
  • 772
  • 1
  • 8
  • 21
36
votes
10 answers

onActivityResult() not called

onActivityResult() is not getting called. Below is my code: @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { // Check which request we're responding to Log.e("CALLED", "OnActivity Result"); if…
Parin Parikh
  • 775
  • 1
  • 6
  • 17
31
votes
4 answers

Start resolution for result in a fragment

In my app if the user doesn't have the location turned on I am prompting with a dialog and then trying to return that result (probably incorrectly) by overriding on activity result. This is inside a fragment so not sure how that changes things: This…
Nicholas Muir
  • 2,897
  • 8
  • 39
  • 89
30
votes
8 answers

How can I call OnActivityResult inside Fragment and how it work?

I want to know is it possible on onActivityResult()to use inside Fragment and if yes then how it works please explain with example.
Shweta Nandha
  • 728
  • 1
  • 8
  • 19
25
votes
1 answer

LocationSettingsRequest returns 0 to onActivityResult even if ok is clicked

I am using following code to show popup to turn on location LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder() .addLocationRequest(mLocationRequest); SettingsClient client =…
22
votes
2 answers

Wrong requestCode returned onActivityResult from another Activity

I have an Activity that calls another Activity, that calls some other Activities. I send to the last Activity to get a result, and then i send back the result to the fist Activity. The flow is somthing like A -> B -> C -> D -> C -> B -> A With the…
Luca
  • 823
  • 4
  • 11
  • 31
21
votes
8 answers

android reduce file size for camera captured image to be less than 500 kb

My requirement is to upload camera captured image to the server, but it should be less than 500 KB. In case, if it is greater than 500 KB, it needs to be reduced to the size less than 500 KB (but somewhat closer to it) For this, I am using the…
21
votes
7 answers

How to use onActivityResult method from other than Activity class

I am creating an app where i need to find current location of user . So here I would like to do a task like when user returns from that System intent, my task should be done after that.(Displaying users current location) So i am planning to use…
Jay Vyas
  • 2,674
  • 5
  • 27
  • 58
19
votes
10 answers

zxing onActivityResult not called in Fragment only in Activity

I'm having some issue with zxing onActivityResult(). As you can see in the code I did properly invoke new intent as described in https://code.google.com/p/zxing/wiki/ScanningViaIntent. The question is how can I catch onActivityResult() in…
5er
  • 2,506
  • 7
  • 32
  • 49
17
votes
4 answers

Start Activity from Fragment using Transition (API 21 support)

I'm trying to port an Android app to the new support library (support-v4:21.0.0) and I'm having trouble starting Activities from Fragments with a transition. In my Activities, I've been doing something like: Bundle options =…
1
2 3
65 66