Skip to content

Snappy1

  • Home
  • Android
  • What
  • How
  • Is
  • Can
  • Does
  • Do
  • Why
  • Are
  • Who
  • Toggle search form

[FIXED] How to implement onAcitvityResult in React Native Android?

Posted on November 11, 2022 By

Solution 1 :

    public final ActivityEventListener mActivityEventListener = new BaseActivityEventListener(){

        @Override
        public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent intent) {
            Log.d("ReactNative",String.valueOf(requestCode));
            Log.d("ReactNative",String.valueOf(resultCode));
     
            // check out the codes on accepting and rejecting the activity
        }
        
    };

In your constructor, Add something like this

      reactContext.addActivityEventListener(mActivityEventListener);

http://reactnative.dev/docs/native-modules-android#getting-activity-result-from-startactivityforresult

Problem :

How to implement the onActivityResult in React Native module
I want to to check the result of launched activity in React Native.
Here it shows the error as ”’cannot find symbole onActivityResult“`

public class RNWhatsAppStickersModule extends ReactContextBaseJavaModule {
...
 public RNWhatsAppStickersModule(ReactApplicationContext reactContext) {
        super(reactContext);
        this.reactContext = reactContext;
    }

 @Override
 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        try {
            super.onActivityResult(requestCode, resultCode, data);
            if (requestCode == REQUEST_CODE  && resultCode  == RESULT_OK) {

                String requiredValue = data.getStringExtra("key");
            }
        } catch (Exception ex) {
            Toast.makeText(Activity.this, ex.toString(),
                    Toast.LENGTH_SHORT).show();
        }

  }
...

}

Comments

Comment posted by famfamfam

this conflict with other module with onActivityResult

READ  [FIXED] php - Unhandled Exception: FormatException: Unexpected character (at character 1) E/flutter ( 6084):
E/flutter ( 6084): ^
Powered by Inline Related Posts
Android Tags:android, react-native

Post navigation

Previous Post: [FIXED] android developer api – there is a ‘Late Initialization Error’ during flutter development
Next Post: [FIXED] android – How to set SSL pinning using retrofit for Firebase Realtime Database Url?

Related Posts

[FIXED] android – Navigation and Drawer Navigation React-Native Android
[FIXED] How to set location persmission granted from custom dialog using flutter Android
[FIXED] firebase – Project level build.gradle not containing the appropriate code Android
[FIXED] android – Kotlin : How to click on item in a Recyclerview Inside another Recyclerview Android
[FIXED] android – Crash with MoPubRecyclerAdapter and Facebook Native Ads in ConstraintLayout Android
[FIXED] cordova – Ionic http get from non-ssl websites with CORS settings Android

Archives

  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022

Categories

  • ¿Cómo
  • ¿Cuál
  • ¿Cuándo
  • ¿Cuántas
  • ¿Cuánto
  • ¿Qué
  • Android
  • Are
  • At
  • C'est
  • Can
  • Comment
  • Did
  • Do
  • Does
  • Est-ce
  • Est-il
  • For
  • Has
  • Hat
  • How
  • In
  • Is
  • Ist
  • Kann
  • Où
  • Pourquoi
  • Quand
  • Quel
  • Quelle
  • Quelles
  • Quels
  • Qui
  • Should
  • Sind
  • Sollte
  • Uncategorized
  • Wann
  • Warum
  • Was
  • Welche
  • Welchen
  • Welcher
  • Welches
  • Were
  • What
  • What's
  • When
  • Where
  • Which
  • Who
  • Who's
  • Why
  • Wie
  • Will
  • Wird
  • Wo
  • Woher
  • you can create a selvedge edge: You can make the edges of garter stitch more smooth by slipping the first stitch of every row.2022-02-04
  • you really only need to know two patterns: garter stitch

Recent Posts

  • Can VPN be traced by police?
  • Where were Kaiser-Frazer cars built?
  • How do you make gold rose gold paint?
  • What are the newest type of dentures?
  • Can you wear joggers as dress pants?

Recent Comments

No comments to show.

Copyright © 2023 Snappy1.

Powered by PressBook Grid Dark theme