@@ -21,12 +21,10 @@ protected void onCreate(Bundle savedInstanceState) {
21
21
super .onCreate (savedInstanceState );
22
22
SoLoader .init (this , false );
23
23
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 );
27
25
List <ReactPackage > packages = new PackageList (getApplication ()).getPackages ();
26
+ // Packages that cannot be autolinked yet can be added manually here, for example:
28
27
29
- mReactRootView = new ReactRootView (this );
30
28
mReactInstanceManager = ReactInstanceManager .builder ()
31
29
.setApplication (getApplication ())
32
30
.setCurrentActivity (this )
@@ -36,51 +34,59 @@ protected void onCreate(Bundle savedInstanceState) {
36
34
.setUseDeveloperSupport (BuildConfig .DEBUG )
37
35
.setInitialLifecycleState (LifecycleState .RESUMED )
38
36
.build ();
39
-
40
- // The string here (e.g. "MyReactNativeApp") has to match
41
37
// the string in AppRegistry.registerComponent() in index.js
42
- mReactRootView .startReactApplication (mReactInstanceManager , "HybridApp" , null );
38
+ mReactRootView .startReactApplication (mReactInstanceManager , "hybridexampleapp" , null );
39
+
43
40
setContentView (mReactRootView );
44
41
}
45
42
46
43
@ Override
47
44
public void invokeDefaultOnBackPressed () {
48
45
super .onBackPressed ();
49
46
}
50
-
51
47
@ 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 ();
58
50
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 );
65
53
}
54
+ }
66
55
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 );
76
62
}
63
+ }
77
64
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 ;
85
89
}
90
+ return super .onKeyUp (keyCode , event );
91
+ }
86
92
}
0 commit comments