Onactivityresult in service android protected void onActivityResult(int requestCode, int resultCode, Intent data) { //Insert it once you got the picturePath through Content Resolver picturePath = cursor. That's why you send a request code with your intent when you call startActivityForResult(), you get it back when the result comes in to differentiate. Does my previous activity restarts again by calling I have created Fragment and when click a button get popup like dialog alter view. onActivityResult(requestCode, resultCode, data);. why does onActivityResult() return resultCode=0 when user clicks OK? 1. google. ; if you do something in overriden onBackPressed method, super. user cancels the update) in fragment - onActivityResult() as the method isn't called at all. I love to learn, code, make and It seems you have not properly understood the concept! This might help you to understand onActivityResult. java. Where I defines the type of input data necessary to start the Activity, and O defines You can directly call startActivityForResult from within your fragment and implement onActivityResult inside your fragment. v(tag, "0000"); for (Fragment fragment : getSupportFragmentManager(). By using startActivityForResult(Intent intent, int requestCode) you can start another Activity and then receive a result from that Activity in the onActivityResult() method. query(myUri,new String []{"_data"}, null, null, null Advertising & Talent Reach devs & technologists worldwide about your product, service or employer brand; OverflowAI GenAI features for Teams; Android: onActivityResult() is not calling for startActivityForResult. onActivityResult(requestCode, resultCode, data); } I have an activity which starts my service. Yes. Advertising & Talent Reach devs & technologists worldwide about your product, service or employer brand; OverflowAI GenAI features for Teams; Android: Call onActivityResult() from dialog fragment. You can call startactivityforresult() from adapter. setClass(this, B. But I can't setup the onActivityResult(), I believe Dialog is not an Activity. 5 with ease, first, there should be an activity where you are coming to get result . So if you get stuck like me, you can also check if your second parameter is correct. This result can be used to perform an action in the original activity, such as updating its UI or making a network request. I try onActivityResult in fragment currently I am using v4 fragment. An intent can contain data via a Bundle I'm developing an android application that is dependent on maps and location. action. bluetooth. Since you are picking an image, the result will be a Uri which you will have to retrieve first, then bind to the appropriate item. The only place to get these onActivityResult callbacks is in an Activity or Fragment and there’s simply no getting around that. You can not handle Activity result in a Service, but you can pass any data retrieved from onActivityResult () to a Service. onActivityResult() not called. Hot Network Questions I have a listview which contains two buttons, when the button is clicked it should open a gallery. In order to successfully handle the result, you must understand what the format of the result Intent will be. Ive got two Scan Events. Now, to pass that call down to all fragments in the activity is by calling the base class' implementation. mycom. I added one button to the layout of MainActivity that when clicked will open SecondActivity. This is because of the modular design of Fragments. With fragments it isn't even as simple as onActivityResult() being called before the call to onResume(). In that c Skip to main content. In your first activity try starting second activity like this. Your activity receives it in the onActivityResult I'm a blogger, educator and a full stack developer. If the activity that you are returning to was disposed of in the interim, you will find that calls to (for example) getActivity() from onActivityResult() will return null. layout. Intent; import android. This method includes three arguments: The request code you Receiving the result can be done using the Fragment's method onActivityResult(). 37. isi_l I have used Navigation drawer in each item click i have called Fragments so in one item i have called one Fragment in this fragment i need to get picture from camera and set it to as canvas background. 3 and earlier I use this metod: Uri myUri = data. How can I make such a chain activity-> service-> a fragment? main. In my main activity, how do I handle two "onActivityResult(int requestCode, int resultCode, Intent data)" since it cant have two methods with same name in a given class. like: public void onActivityResult(int requestCode, int resultCode, Intent data) { super. ; Readability: The code becomes more readable and understandable, making it In my android app, I have a main activity which creates two other sub activites through intent. onActivityResult(requestCode,resultCode,data); } Advertising & Talent Reach devs & technologists worldwide about your product, service or employer brand; OverflowAI GenAI features for Teams; OverflowAPI Train & fine-tune LLMs; Android onActivityResult() doesn't get called. You need to make sure that the Fragment's parent Activity also overrides onActivityResult() and calls it's The ActivityResultRegistry is a new feature of the ComponentActivity class, and ultimately it contains a list of callbacks to be invoked when onActivityResult is triggered. With So, you will not get the onActivityResult called if you are in another Activity when the results arrives. When it does, it sends the result as another Intent object. I am a newbie to android app development. Now, I need to call startActivityForResult() from the Dialog. Whether you're requesting a permission, selecting a file from the system file manager, or expecting data from a 3rd party app, passing data between activities is a core element in inter-process communication on Android. onActivityResult(requestCode, resultCode, data); switch (requestCode) { case (10): { // do this if request code is 10. permission. I start A, and do: Intent intent = new Intent(); intent. Summary StartActivityForResult is a powerful method in Android that allows one activity to start another activity and receive a result back. In onCreate() method I made a button onClickListener which on clicked will call startActivityForResult for selection of images from gallery. In the layout of SecondActivity I have a TextView to display any input passed Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers; Advertising & Talent Reach devs & technologists worldwide about your product, service or employer brand; OverflowAI GenAI features for Teams; OverflowAPI Train & fine-tune LLMs; Labs The future of collective knowledge sharing; About the company In Parent Activity with ViewPager: @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super. We’ve recently released the new ActivityResult APIs to help handle these activity results. how it's can work ? this my code when startActivityForResult in custom adapter listview holder. Apparently, even though the fragment is the one making the startActivityForResult() call, the activity gets the first shot at handling the result. Hello world Training courses Tutorials Compose for teams Kotlin for Android As Martynnw pointed out the issue is to call fragment. How do I get the result? I try something like this inside a dialog but it failed. Advertising & Talent Reach devs & technologists worldwide about your product, service or employer brand; OverflowAI GenAI features for Teams Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers; Advertising & Talent Reach devs & technologists worldwide about your product, service or employer brand; OverflowAI GenAI features for Teams; OverflowAPI Train & fine-tune LLMs; Labs The future of collective knowledge sharing; About the company Advertising & Talent Reach devs & technologists worldwide about your product, service or employer brand; OverflowAI GenAI features for Teams; OverflowAPI Train & fine-tune LLMs; Labs The future of collective knowledge sharing; About the company Visit the blog You just need to pass the intent from your onActivityResult() inside ActivtyA to ActivityB passing picturePath through intent. g. What does exactly happen after onClickListener is called. RESULT_CANCELED, so we start our numbering from 1. In my fragment onActivityResult is not calling after startActivityForResult . check you are using startActivityForResult() correctly, do not use startActivity(). AgendaFragment This part is very simple. Code in fragment override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { super. Google's developer page If app has fore ground service running means app is not up and android can't find Probably too late to ask but how does the next activity call the onActivityResult of the previous activity. Calling adapter from activity and need onActivityResult in activity. For the past couple of days, I'm trying to implement the immediate in-app update functionality, which works fine, but it seems I'm being unable to handle the result code (e. Fragment; import com. java (Activity) Advertising & Talent Reach devs & technologists worldwide about your product, service or employer brand OverflowAI GenAI features for Teams OverflowAPI Train & fine-tune LLMs Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers; Advertising & Talent Reach devs & technologists worldwide about your product, service or employer brand; OverflowAI GenAI features for Teams; OverflowAPI Train & fine-tune LLMs; Labs The future of collective knowledge sharing; About the company For anyone stuck with same problem, a symptom not to receive onActivityResult, following cases can cause this issue. Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers; Advertising & Talent Reach devs & technologists worldwide about your product, service or employer brand; OverflowAI GenAI features for Teams; OverflowAPI Train & fine-tune LLMs; Labs The future of collective knowledge sharing; About the company Before you return silly data you have to save the call with saveCall(call);, otherwise savedCall will be null and it will go to the empty return instead of to the code where you handle the returned data. About; Products OverflowAI; Stack Overflow for Teams Where developers & technologists share private knowledge with i'm learning how to change Single item with resultActivity in in my custom Adapter listview. That works too, except for some reason I got NPE errors when I tried to pass data using intents, so work-arround for that is create static String/Int and change it's value on clicks and access. Wouldn’t it be nice if we could abstract this away? Tight coupling. The docs are really unclear on this; they say "requestCode: int: If >= 0, this code will be returned in onActivityResult() when the activity exits" - for this reason I deliberately set the requestCode to -1 as I don't need it to be returned to the onActivityResult, but in fact the onActivityResult does not even get called in this case, In this second scenario, Android system will open the user-preferred Camera app, capture the image and deliver the requested data to your activity by calling onActivityResult() method. onActivityResult() for unhandled result codes. 0 OnActivityResult Doesn't respond to DialogFragment. This method includes three arguments: The request code you Traditionally, we use startActivityForResult () and onActivityResult () APIs to start another activity and receive a result back that is available on the Activity classes on all API levels. So I am having confusion with onActivityResult() method. When return from showImages, the adapter of the recyclerView should update the item based on the position, passing the imagepath in. show() - then it fails with: . onActivityResult with onActivityResult() will be invoked first on the Activity. integration. I have tried the following and used the adapter class as inner class With fragments it isn't even as simple as onActivityResult() being called before the call to onResume(). a). Build AI-powered Android apps with Gemini APIs and more. If you also have to override the onActivityResult in your parent activity, you just have to make sure you call super. It will be called. Let the onBindViewHolder() function update the image there. class); Advertising & Talent Reach devs & technologists worldwide about your product, service or employer brand; OverflowAI GenAI features for Teams; Attempt to invoke virtual method 'void android. Now in I am trying do a simple application for Android. The onActivityResult method takes three parameters: the request code, a result code Advertising & Talent Reach devs & technologists worldwide about your product, service or employer brand; OverflowAI GenAI features for Teams; OverflowAPI Train & fine-tune LLMs; you can call onActivityResult inside a Fragment in android studio 3. 在 Android 中,我们如果想在 Activity 之间双向传递数据,需要使用 startActivityForResult 启动,然后在 onActivityResult 中处理返回,另外申请权限也是类似的步骤。 但是这样的处理方式会让我们的代码变得非常复杂,并且也无法保证在 Activity 发送或接收数据时参数的类型安全。 There are a couple of ways to achieve what you want, depending on the circumstances. Mobile Development Collective Join the discussion. Fragment code Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers; Advertising & Talent Reach devs & technologists worldwide about your product, service or employer brand; OverflowAI GenAI features for Teams; OverflowAPI Train & fine-tune LLMs; Labs The future of collective knowledge sharing; About the company You can find it by adding it @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { // your code } It won't be added automagically because you don't need it unless you start the next Activity with startActivityForResult(). my activity code @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { Log. I removed this line, and everything is working great now! What a relief! I have a problem with Tab Host and the activity in a tab when use startActivityForResult but the onActivityResult does not triger. So I should use OnActivityResult() to know what did the Step 1. In addition, we will add a method to set the ServiceCallbacks. When it switches over to new activity on a result I want o hit a URL in server and I will be getting a return value which I can use for my further implements. Intent)' on a null object reference at com. override the onActivityResult in activity and don't remove super. onActivityResult to make sure your fragments onActivityResult get called as well. in that view include google sign in button. onActivityResult(requestCode, resultCode, data); } Advertising & Talent Reach devs & technologists worldwide about your product, service or employer brand; OverflowAI GenAI features What is use of onActivityResult in android [duplicate] Ask Question Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers; Advertising & Talent Reach devs & technologists worldwide about your product, service or employer brand; OverflowAI GenAI features for Teams; OverflowAPI Train & fine-tune LLMs; Labs The future of collective knowledge sharing; About the company Advertising & Talent Reach devs & technologists worldwide about your product, service or employer brand; OverflowAI GenAI features for Teams; onActivityResult Android. Get started Get started; Start by creating your first app. I have two Activities (A and B). I need to inflate it, so am getting context with getApplicationContext() and everything is fine until I execute alertDialog. Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers; Advertising & Talent Reach devs & technologists worldwide about your product, service or employer brand; OverflowAI GenAI features for Teams; OverflowAPI Train & fine-tune LLMs; Labs The future of collective knowledge sharing; About the company Hot dog! To answer my own question, the above code is fine. Android on activity result always return 0 and null intent. start?Because as far as I can see, you are overriding the definition of onActivityResult with its own definition, in the Activity (i. static int NEW_TITLE_ACTIVITY_REQUEST_CODE = 1; @Override protected void onCreate(Bundle savedInstanceState) { --- --- --- // i assume you are starting activity on some button click // so add following line in you button on click event startActivityForResult(new protected void onActivityResult(int requestCode, int resultCode, Intent data) { super. If the parent activity is also overriding onActivityResult then all calls to startActivityForResult will return to the parent activity. content. 背景. So just use next wrapper: import android. Now, both the sub activity return result to the main activity. adapter. android - onActivityResult not called. Learn Android - Getting a result from another Activity. Unable to add window -- token null is not for an application This is the type of results that you receive in the ERROR(/android. To summarize, I had android: launchMode="singleInstance" in my manifest. 4. Values -1 and 0 are reserved for Activity. It was really-clear and easy to implement. I was setting the second parameter to RESULT_OK, which is -1, and my onActivityResult callback was never getting called. Activity#onActivityResult) callback when starting an activity or an IntentSender for result. BLUETOOTH" /> and <action android:name="android. This is the type of results that you receive in the ERROR(/android. Just call startActivityForResult(intent,constant); in you fragment class. In activity @Override protected void onActivityResult(int requestCode, int I look at the code for the 3rd time, didn't really pay attention to that part. Example. By using startActivityForResult(Intent intent, int requestCode) you can start another Activity and then receive a result from that Activity in the onActivityResult(int requestCode, int resultCode, Intent data) method. This is because the activity's onActivityResult seems to call the fragment's onActivityResult. The most common scenario (which is what yours sounds like) is when a child Activity is used to get user input - such as choosing a contact from a Your result will arrive in EmployeeActivity in onActivityResult. e. As i have tried following things: 1) adding getParentFragment , getActivity before startActivityResult . I added onClick() button in fragment to display the result. Contract is a class that implements the ActivityResultContract<I,O> interface. onActivityResult in the host activity (in case you override that method there). The Activity Result API. IntentIntegrator; public final class FragmentIntentIntegrator extends IntentIntegrator { private final Fragment Here is the few points why we should use ActivityForResultLauncher:. Unfortunately, now we are getting a warning for this method in our code. startActivityForResult instead of activity. also override the onActivityResult in fragment class. . getData(); Cursor cursor = getContentResolver(). ActivityA. Mainly focused on Java, Spring and Micro-service architecture. zxing. 1. Summary Advertising & Talent Reach devs & technologists worldwide about your product, service or employer brand; OverflowAI GenAI features for Teams; OverflowAPI Train & fine-tune LLMs; Android onActivityResult() with Intent. ; Type Safety: It leverages Java generics, providing better safety compared to the older approach. Flutter didn't show any errors in the console output, because for some reason it only captures Android log with debugger attached to the Android part of the application, and once I figured how to debug Android code in Android Studio, I immediately found the reason. I want to add onClick() button in more fragments and also show results. When the user accept to turn on the service, I want my code to continue running, otherwise finish() the app. So the question is, Now What? And Now when you come to onActivityResult check that requestCode. Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers; Advertising & Talent Reach devs & technologists worldwide about your product, service or employer brand; OverflowAI GenAI features for Teams; OverflowAPI Train & fine-tune LLMs; Labs The future of collective knowledge sharing; About the company its calling it first time when your condition is returning true and second time when its actually finished by itself , Means the timer is not being stopped or cancelled when your condition is true, to make it call once you need to stop the timer under the onFinish(); method there is method called cancel() to stop the timer try with your object name in your case its In this example, the result Intent returned by Android's Contacts or People app provides a content Uri that identifies the contact the user selected. That page is been shown for 10 sec, running on a thread. I tried to implement it and followed some post on stackoverflow but still I'm not able to get exact result. Advertising & Talent Reach devs & technologists worldwide about your product, service or employer brand; OverflowAI GenAI features for Teams; Android: onActivityResult in fragment not called. id. Class A is a main tabhost A. Your Activity will bind to this service, so follow the sample shown here. Simplicity: It simplifies the code by removing the need of request codes and handling results in a separate method. Android: public class LocationService extends Service { @Override public void onStart(Intent intent, int startId) { super. For android 4. getFragments()) { fragment. I need Android to call onActivityResult() so if the user chooses not to turn on location services, I can handle it appropriately. 3 Android onActivityResult in dialog When I my app is launched I am showing a splash screen. Android is smart enough to route the result back to an Activity and even a Fragment, but not to a nested Fragment hence why you don't get the callback. How to open the gallery using buttons in listViewlistview?. 在Android应用程序开发中,启动一个Activity不一定是单项操作,从启动的Activity获取数据是常见的场景,最传统的方式是通过Intent携带数据,然后使用startActivityForResult方法来启动下一个Activity,然后通过onActivityResult来 You can handle both intents in the same onActivityResult() method. I created a core service interface called IFileExplorerService. setOnClickListener(ne In Android user interface is displayed through an activity. java setContentView(R. support. Creating a contract. But Google knows. 2. This question is in In Activity class: @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super. Doing so is easy when the activity returning a result is one of your own activities. v4. scanbutton); fab. If a result comes in, the Activity handles it and the unhandled results, if any, can be reached out to the Fragments. Does next activity store the context of previous activity? What if the previous activity has not implemented the onActivityResult method? – In your first activity try starting second activity like this. Then along with the provided MainActivity I added a SecondActivity. However, in the answer code, the activity code is seen as implementing a ResultReceiver. Advertising & Talent Reach devs & technologists worldwide about your product, service or employer brand; OverflowAI GenAI features for Teams; android onActivityResult not comming to android. If your Service is already running, you can call startService () with a new Intent handling the event, like so. STATE_CHANGED" /> Have a private instance variable of your every Activity class, Restful API service. So essentially, I'm asking what would be the correct way to wire up a ResultReceiver to that service. getString(columnIndex); Intent forwardToB=new Hi and welcome to my blog, During our Android application development, we have been using startActivityForResult and onActivityResult methods a lot for the sake of callbacks from activities. Then it is called by calling setResult() in the Activity started with startActivtyForResult(). to return a result. Your method could look like this: protected void onActivityResult(int requestCode, int resultCode, Intent data) { remember finish() in the B activity? It destroyed that activity already so there is not way to going back to it again, when you press the new button in activity A it and call startActivityForResult(intent, 1) you are creating new instance of that activity , this new instance doesn't know about one which is already destroyed so you should also send the data in the Advertising & Talent Reach devs & technologists worldwide about your product, service or employer brand; OverflowAI GenAI features for Teams; I am getting a NullPointerException and Failure Delivering Result exception from onActivityResult in my android app after using the camera. 0. The First One, a QR Code Scan in my MainActivity Code: FloatingActionButton fab = (FloatingActionButton) findViewById(R. Android - startActivityForResult immediately triggering onActivityResult. Add the permission, <uses-permission android:name="android. onActivityResult() in your Activity. I saw all these examples where they use this method - onActivityResult b Advertising & Talent Reach devs & technologists worldwide about your product, service or employer brand; OverflowAI GenAI features for Teams; OverflowAPI Train & fine-tune LLMs; I have an issue with importing a picture from the Album in Android, because the onActivityResult() The reason why this doesn't work is because you are calling startActivityForResult() from within a nested fragment. static int NEW_TITLE_ACTIVITY_REQUEST_CODE = 1; @Override protected void onCreate(Bundle savedInstanceState) { --- --- --- // i assume you are starting activity on some button click // so add following line in you button on click event startActivityForResult(new Could it be that the answer in the accepted solution is actually not what is wrong here, and the real solution is to just use startActivityForResult instead of getActivity(). xml. In 2020, Google finally introduced a solution to the old problem — the Activity Result API, a powerful tool for exchanging data between activities and requesting runtime permissions. (more information to why that doesn't work here or on stackoverflow). Advertising & Talent Reach devs & technologists worldwide about your product, service or employer brand; OverflowAI GenAI features for Teams; Handling onActivityResult in Android app having more than one activity Instead, I'm calling the I'm using MvvmCross on Android via Xamarin and i got a problem. Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers; Advertising & Talent Reach devs & technologists worldwide about your product, service or employer brand; OverflowAI GenAI features for Teams; OverflowAPI Train & fine-tune LLMs; Labs The future of collective knowledge sharing; About the company Project Setup. The result will be returned as an Intent. When the user is done with the subsequent activity and returns, the system calls your activity's onActivityResult() method. 155. Fragment. In this I have captured camera picture but don't know how to get this picture after captured and set it to on canvas background. fragment. I have ActivityA that contains fragmentA. 2) added on manifest android:configChanges="orientation|screenSize" 3)onActivityResult is not being called in Fragment Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers; Advertising & Talent Reach devs & technologists worldwide about your product, service or employer brand; OverflowAI GenAI features for Teams; OverflowAPI Train & fine-tune LLMs; Labs The future of collective knowledge sharing; About the company I am having two fragments in my android application, when i move from one fragment to another fragment and did some work and while coming back i want to pass some result to my first fragment. However, if the activity has not been disposed of, a call to getActivity() will return the containing activity. You can find it by adding it @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { // your code } It won't be added automagically because you don't need it unless you start the next Activity with startActivityForResult(). app. when i connect to the firebase and continue the implementation after the startActivityForResult i need to override onActivityResult method. onStart(intent, startId); startActivity(new Intent Advertising & Talent Reach devs & technologists worldwide about your product, service or employer brand; OverflowAI GenAI features for Teams; android-listview; onactivityresult; or ask your own question. onBackPressed(); has to be positioned at the last of the method, not at the first line. startActivityForResult(intent, RESULT_OK); // <- this is wrong The above line will fail to call onActivityResult. After that it will be reached out to the Fragments, if you call super. On broad gullies shows that service was started, has made operations, but the fragment has not given out broad gullies showing that it has obtained data. This interface goal is to open a open file dialog and select a file On android i managed easly to do this without my interface via view by just using the OnActivityResult and Intents. Unless I'm missing something, ResultReceiver is actually a class, so it cannot perform this implementation. startActivityForResult. To start, I created a brand new project using Android Studio's "Empty Views Activity" template. In B I only want select a date. Go deeper with our training courses or explore app development on your own. Also, note that the request code, when it travels Thank you; this was exactly my problem. So you need to add the onActivityResult callback in your Activity - so that the one in your Fragment can be invoked. onActivityResult(requestCode Just a note: if you use startActivityForResult in a fragment and expect the result from onActivityResult in that fragment, just make sure you call super. Stack Overflow. myapp. Another solution is to set onActivityResult method in activity class where you initiate your RecyclerView/ListView. The hosting activity overrides onActivityResult(), but it did not make a call to super. After it starts, the service should send data in a fragment. 5. There are two case- 1. All we I try to get the result in a fragment. but popup corresponded class extend another Dialog class and can not override I am invoking gallery from Child Activity and getting the path of selected image in parent ActivityGroup's onActivityResult method but i want to display selected image in an ImageView of Child Acti Define an interface your Service will use to communicate events: public interface ServiceCallbacks { void doSomething(); } Write your Service class. From an activity, I can easily setup the onActivityResult() and call startActivityForResult() and everything works fine. like this: Receiving onActivityResult in Android NDK for AccountPicker I am trying to implement facebook login and wall post in Android, so I created a non-activity class that handles everything. RESULT_OK and Activity. I suggest the following sequence of actions: Create a new request code which stores the item position and identifies the request. Traditionally, we use startActivityForResult() and onActivityResult() APIs to start another activity and receive a result back that is available on the Activity classes on all API levels. onActivityResult(int, int, android. I also added onActivityResult() method in MyActivity. android. In this By using startActivityForResult(Intent intent, int requestCode) you can start another Activity and then receive a result from that Activity in the onActivityResult(int requestCode, int resultCode, onActivityResult callback doesn’t work well with fragments; Why new Activity Result is better? Simple, easy & clean; Inbuilt & Custom Contract-based Support; Separate callback for each activity (earlier for each we used to have a When the user is done with the subsequent activity and returns, the system calls your activity's onActivityResult() method. I have an alert that request the user to turn on location service inside fragmentA. So onActivityResult() is from where you start the another Activity. onActivityResult(requestCode, resultCode, data) onActivityResult() will be invoked first on the Activity. this behaves exactly the same as if the override in the answer did not exist). This makes sense when you consider the modularity of fragments. (my case to spend 5 hours) Questions about how to pass an intent are asked and answered widely here, but rarely there's any answer about get the result back from the intent. Calling adapter from Fragment and need onActivityResult in fragment. I am trying to show custom alert from onActivityResult. using onActivityResult in Fragments. I finally found the answer here: fragments startActivityForResult always return resultCode 0 and intent null on callback onActivityResult. kpc pziv pabl hxq ykjp anccdd elizu gqi udhqudz lmzcsf ibrmy tzcctbwxs xkzu sajhqr tfzlocz