@@ -21,12 +21,10 @@ protected void onCreate(Bundle savedInstanceState) {
2121 super .onCreate (savedInstanceState );
2222 SoLoader .init (this , false );
2323
24- // Packages that cannot be autolinked yet can be added manually here, for example:
25- // packages.add(new MyReactNativePackage());
26- // Remember to include them in `settings.gradle` and `app/build.gradle` too.
24+ mReactRootView = new ReactRootView (this );
2725 List <ReactPackage > packages = new PackageList (getApplication ()).getPackages ();
26+ // Packages that cannot be autolinked yet can be added manually here, for example:
2827
29- mReactRootView = new ReactRootView (this );
3028 mReactInstanceManager = ReactInstanceManager .builder ()
3129 .setApplication (getApplication ())
3230 .setCurrentActivity (this )
@@ -36,51 +34,59 @@ protected void onCreate(Bundle savedInstanceState) {
3634 .setUseDeveloperSupport (BuildConfig .DEBUG )
3735 .setInitialLifecycleState (LifecycleState .RESUMED )
3836 .build ();
39-
40- // The string here (e.g. "MyReactNativeApp") has to match
4137 // the string in AppRegistry.registerComponent() in index.js
42- mReactRootView .startReactApplication (mReactInstanceManager , "HybridApp" , null );
38+ mReactRootView .startReactApplication (mReactInstanceManager , "hybridexampleapp" , null );
39+
4340 setContentView (mReactRootView );
4441 }
4542
4643 @ Override
4744 public void invokeDefaultOnBackPressed () {
4845 super .onBackPressed ();
4946 }
50-
5147 @ Override
52- protected void onPause () {
53- super .onPause ();
54- if (mReactInstanceManager != null ) {
55- mReactInstanceManager .onHostPause (this );
56- }
57- }
48+ protected void onPause () {
49+ super .onPause ();
5850
59- @ Override
60- protected void onResume () {
61- super .onResume ();
62- if (mReactInstanceManager != null ) {
63- mReactInstanceManager .onHostResume (this ); // Corrected the method call
64- }
51+ if (mReactInstanceManager != null ) {
52+ mReactInstanceManager .onHostPause (this );
6553 }
54+ }
6655
67- @ Override
68- protected void onDestroy () {
69- super .onDestroy ();
70- if (mReactInstanceManager != null ) {
71- mReactInstanceManager .onHostDestroy (this );
72- }
73- if (mReactRootView != null ) {
74- mReactRootView .unmountReactApplication ();
75- }
56+ @ Override
57+ protected void onResume () {
58+ super .onResume ();
59+
60+ if (mReactInstanceManager != null ) {
61+ mReactInstanceManager .onHostResume (this , this );
7662 }
63+ }
7764
78- @ Override
79- public void onBackPressed () {
80- if (mReactInstanceManager != null ) {
81- mReactInstanceManager .onBackPressed ();
82- } else {
83- super .onBackPressed ();
84- }
65+ @ Override
66+ protected void onDestroy () {
67+ super .onDestroy ();
68+
69+ if (mReactInstanceManager != null ) {
70+ mReactInstanceManager .onHostDestroy (this );
71+ }
72+ if (mReactRootView != null ) {
73+ mReactRootView .unmountReactApplication ();
74+ }
75+ }
76+ @ Override
77+ public void onBackPressed () {
78+ if (mReactInstanceManager != null ) {
79+ mReactInstanceManager .onBackPressed ();
80+ } else {
81+ super .onBackPressed ();
82+ }
83+ }
84+ @ Override
85+ public boolean onKeyUp (int keyCode , KeyEvent event ) {
86+ if (keyCode == KeyEvent .KEYCODE_MENU && mReactInstanceManager != null ) {
87+ mReactInstanceManager .showDevOptionsDialog ();
88+ return true ;
8589 }
90+ return super .onKeyUp (keyCode , event );
91+ }
8692}
0 commit comments