1 package dev.expo.payments;
2 
3 import android.app.Application;
4 import android.content.res.Configuration;
5 
6 import com.facebook.react.PackageList;
7 import com.facebook.react.ReactApplication;
8 import com.facebook.react.ReactNativeHost;
9 import com.facebook.react.ReactPackage;
10 import com.facebook.react.config.ReactFeatureFlags;
11 import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint;
12 import com.facebook.react.defaults.DefaultReactNativeHost;
13 import com.facebook.soloader.SoLoader;
14 
15 import java.util.List;
16 
17 import androidx.annotation.NonNull;
18 import androidx.annotation.Nullable;
19 import expo.modules.ReactNativeHostWrapper;
20 import expo.modules.ApplicationLifecycleDispatcher;
21 import expo.modules.devlauncher.DevLauncherPackageDelegate;
22 import expo.modules.devmenu.DevMenuPackageDelegate;
23 
24 public class MainApplication extends Application implements ReactApplication {
25   static final boolean USE_DEV_CLIENT = false;
26 
27   private final ReactNativeHost mReactNativeHost =
28     new ReactNativeHostWrapper(this, new DefaultReactNativeHost(this) {
29       @Override
30       public boolean getUseDeveloperSupport() {
31         return BuildConfig.DEBUG;
32       }
33 
34       @Override
35       protected List<ReactPackage> getPackages() {
36         return new PackageList(this).getPackages();
37       }
38 
39       @Override
40       protected String getJSMainModuleName() {
41         return ".expo/.virtual-metro-entry";
42       }
43 
44       @Override
45       protected boolean isNewArchEnabled() {
46         return BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
47       }
48 
49       @Override
50       protected Boolean isHermesEnabled() {
51         return BuildConfig.IS_HERMES_ENABLED;
52       }
53     });
54 
55   @Override
getReactNativeHost()56   public ReactNativeHost getReactNativeHost() {
57     return mReactNativeHost;
58   }
59 
60   @Override
onCreate()61   public void onCreate() {
62     super.onCreate();
63     SoLoader.init(this, /* native exopackage */ false);
64     if (!BuildConfig.REACT_NATIVE_UNSTABLE_USE_RUNTIME_SCHEDULER_ALWAYS) {
65       ReactFeatureFlags.unstable_useRuntimeSchedulerAlways = false;
66     }
67     if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
68       // If you opted-in for the New Architecture, we load the native entry point for this app.
69       DefaultNewArchitectureEntryPoint.load();
70     }
71     ReactNativeFlipper.initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
72     if (!USE_DEV_CLIENT) {
73       DevLauncherPackageDelegate.enableAutoSetup = false;
74       DevMenuPackageDelegate.enableAutoSetup = false;
75     }
76     ApplicationLifecycleDispatcher.onApplicationCreate(this);
77   }
78 
79   @Override
onConfigurationChanged(@onNull Configuration newConfig)80   public void onConfigurationChanged(@NonNull Configuration newConfig) {
81     super.onConfigurationChanged(newConfig);
82     ApplicationLifecycleDispatcher.onConfigurationChanged(this, newConfig);
83   }
84 }
85