How to get onActivityResult data from external application activity using seResult or startActivityForResult

I have two applications separately. Application for customers and sellers. I want to pay money for a client application and get a response to the seller’s application. Anyway, I have a deep binding concept included in the seller’s application. Client application: It contains three activity pages in the app.getting client applications (first activity page) and shows confirmation (second action), and payment - the third action. Note. Open the “Client” application using the “Sales” application, fill in all the data and payment from the client application and send a response to the “Seller” application. for this client side, I set the code for this:

Intent object = new Intent(); object.putExtra("data", "3434434343343"); setResult(Activity.RESULT_OK, object); finish(); 

for seller app code:

 protected void onActivityResult(int ResCode, int ReqRes, Intent data) { super.onActivityResult(ResCode, ReqRes, data); if (ResCode == 1 && ReqRes == Activity.RESULT_OK && data != null) { String response = data.getStringExtra("data"); } } 

Problem Here: on the client side Pass data successfully using setResult.then, seller application activity successfully calls onActivityResult, but, Intent data comes in only as NULL. Since here the client side uses several actions, using only then, I skip the result. It is my problem. In any case, to get onActivityResult from several actions with a chain of links (external application actions), this is useful for me.

Note. I found one solution if two applications have the same kind of activity. Its setresult and OnactivityResult correctly call and receive data. But my scenario, if for a few chain links for the Client Side application.

Please help get out with this problem. Thanks Advance

+2
android android-intent startactivityforresult onactivityresult
Aug 03 '16 at 6:08
source share
2 answers

Depending on your use case above, I believe that the best architecture that would allow such communication would be if the client application uses the Fragment installation. Here you can start client activity from the seller application so that the user can go to different fragments and then use setResult() whereverver. Since this is an individual behavior with the setting of the result of activity, it should work.

Another suggestion that you can try, given that you do not want to follow the fragment path, is in the client application, since the user moves to different actions, you can immediately call finish() on them, and then in the last call to the setResult() activity setResult() It probably won't work, but a [very] small part of me says it can :).

+1
Aug 03 '16 at 7:14
source share

You can navigate from ThirdActivity to FirstActivity , and then return to your seller in the onNewIntent method of your FirstActivity .

After completing all three procedures, your client application should have the following stacks.

 FirstActivity -> SecondActivity -> ThirdActivity 

And your ThirdActivity is at the top of the stack. Your ThirdActivity can go to FirstActivity using the following code

 Intent toFirstIntent = new Intent(this, FirstActivity.class); toFirstIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); toFirstIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); startActivity(toFirstIntent); finish(); 

Then in FirstActivity you can set the data and return to your seller.

 @Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); Intent data = new Intent(); data.putExtra("data", "12345678"); setResult(RESULT_OK, data); finish(); } 
-one
Aug 03 '16 at 12:39
source share



All Articles