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
16
votes
4 answers

Alternative to onActivityResult for startUpdateFlowForResult

What is the alternative to get callback for startUpdateFlowForResult in InAppUpdates instead of onActivityResult since it is deprecated?
16
votes
2 answers

New result API error : Can only use lower 16 bits for requestCode

Today I switched to the new ResultAPI and I faced this error: java.lang.IllegalArgumentException: Can only use lower 16 bits for requestCode at androidx.fragment.app.FragmentActivity.checkForValidRequestCode(FragmentActivity.java:715) at…
16
votes
6 answers

Android : When do we use getIntent()?

I dont' understand why we use method getIntent(). Because, when we need that method, We can use method onActivityResult(). But by using the method getIntent(), it could cause NullPointerException.
LKM
  • 2,410
  • 9
  • 28
  • 53
15
votes
3 answers

onActivityResult() deprecated for AppCompatActivity

I am using in-app updates for android and as per the documentation, they are using onActivityResult to handle app behaviour incase the update is interrupted. This is my function that is called from my fragment: private fun…
Hashir Ali
  • 191
  • 2
  • 10
14
votes
1 answer

Android Activity Results API unresolved reference in AppCompatActivity

I'm trying to use the new Activity Results API to replace startActivityForResult. If I call registerForActivityResult in a Fragment everything is OK. However if I call the same method in an AppCompatActivity the IDE displays an "unresolved…
iClaude
  • 707
  • 8
  • 14
14
votes
6 answers

resultCode is always 0 and request is always -1, . Activity.onActivityResult();

I would like to add this to another list of questions about resultCode == 0 and requestCode == 0. Here is the synopsis: NoteActivity calls NoteSettingsActivity using startActivityForResult(). I have searched the web and when I pressed back button…
Neon Warge
  • 1,817
  • 6
  • 29
  • 53
13
votes
3 answers

Attempting to launch an unregistered ActivityResultLauncher

Sometimes I'm getting this IllegalStateException, and it says that you must ensure the ActivityResultLauncher is registered before calling launch(). But there is no method to check if ActivityResultLauncher is registered. How can I solve this and…
user1242192
  • 141
  • 1
  • 5
13
votes
2 answers

Failure delivering result on activity result

Below here sample code intent from camera : val intent = Intent(MediaStore.ACTION_IMAGE_CAPTURE) startActivityForResult(intent, REQUEST_CAMERA) Note: when I press back from camera as result on Activity result show like…
Mohd Hafiz
  • 177
  • 2
  • 12
13
votes
7 answers

onActivityResult() not executing in fragment when i call startResolutionForResult

Problem when i am calling to enable gps programatically using GoogleApiClient into fragment... My code is.. final Status status = result.getStatus(); final LocationSettingsStates state = result.getLocationSettingsStates(); …
Rakesh kushwaha
  • 709
  • 1
  • 10
  • 22
12
votes
3 answers

onActivityResult is deprecated how do I send startResolutionForResult

So I'm using a gps class to turn on the gps and here's a method that allow us to send to onActivityResult, but since is deprecated on AndroidX and still available, android team recommend us the next: it is strongly recommended to use the Activity…
Barrufet
  • 495
  • 1
  • 11
  • 33
12
votes
3 answers

Properly start Activity from Notification regardless of app state

I have an app with a splash screen Activity, followed by a main Activity. The splash screen loads stuff (database, etc.) before starting the main Activity. From this main Activity the user can navigate to multiple other child Activities and back.…
Krøllebølle
  • 2,878
  • 6
  • 54
  • 79
11
votes
1 answer

deprecated OnActivityResult() in androidx

OnActivityResult() is deprecated in androidx. I took reference from below…
11
votes
6 answers

onActivityResult not call in the Fragment

The structure of the app is like this: tabHost (in Activity) -> contains -> TabFragment(extend base container fragment) 1. The code in Activity: tabHost.addTab( tabHost.newTabSpec("home").setIndicator("", …
10
votes
1 answer

ACTION_INSTALL_PACKAGE

My app is trying to install an APK. Intent installIntent = new Intent(Intent.ACTION_INSTALL_PACKAGE); installIntent.setData(Uri.fromFile(new File(pathToApk))); installIntent.putExtra(Intent.EXTRA_NOT_UNKNOWN_SOURCE,…
Akh
  • 5,961
  • 14
  • 53
  • 82
10
votes
5 answers

onActivityResult returns null data for an Image Capture

@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); filePath = getOutputMediaFile(FileColumns.MEDIA_TYPE_IMAGE); File file = new File(filePath); Uri output = Uri.fromFile(file); …
Archie.bpgc
  • 23,812
  • 38
  • 150
  • 226
1
2
3
65 66