This repository was archived by the owner on Oct 5, 2023. It is now read-only.
File tree 2 files changed +34
-0
lines changed
sample-app/android/app/src/main/java/com/hudl/oss/react/sampleapp
2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -41,6 +41,20 @@ Fragment messagingFragment = new ReactFragment.Builder()
41
41
.build();
42
42
```
43
43
44
+ In your Activity make sure to override ` onKeyUp() ` in order to access the In-App Developer menu:
45
+
46
+ ``` java
47
+ @Override
48
+ public boolean onKeyUp(int keyCode, KeyEvent event) {
49
+ boolean handled = false ;
50
+ Fragment activeFragment = getSupportFragmentManager(). findFragmentById(R . id. container_main);
51
+ if (activeFragment instanceof ReactFragment ) {
52
+ handled = ((ReactFragment ) activeFragment). onKeyUp(keyCode, event);
53
+ }
54
+ return handled || super . onKeyUp(keyCode, event);
55
+ }
56
+ ```
57
+
44
58
## Running Sample App
45
59
46
60
NOTE: Make sure your environment is set up for [ React Native] ( https://facebook.github.io/react-native/docs/getting-started.html ) and [ Android] ( https://developer.android.com/training/index.html ) development.
Original file line number Diff line number Diff line change 1
1
package com .hudl .oss .react .sampleapp ;
2
2
3
+ import android .support .v4 .app .Fragment ;
3
4
import android .support .v7 .app .AppCompatActivity ;
4
5
import android .os .Bundle ;
6
+ import android .view .KeyEvent ;
5
7
6
8
import com .facebook .react .modules .core .DefaultHardwareBackBtnHandler ;
7
9
import com .hudl .oss .react .fragment .ReactFragment ;
@@ -29,4 +31,22 @@ protected void onCreate(Bundle savedInstanceState) {
29
31
public void invokeDefaultOnBackPressed () {
30
32
super .onBackPressed ();
31
33
}
34
+
35
+ /**
36
+ * Forward onKeyUp events to the ReactFragment in order to handle double tap reloads
37
+ * and dev menus
38
+ *
39
+ * @param keyCode
40
+ * @param event
41
+ * @return true if event was handled
42
+ */
43
+ @ Override
44
+ public boolean onKeyUp (int keyCode , KeyEvent event ) {
45
+ boolean handled = false ;
46
+ Fragment activeFragment = getSupportFragmentManager ().findFragmentById (R .id .container_main );
47
+ if (activeFragment instanceof ReactFragment ) {
48
+ handled = ((ReactFragment ) activeFragment ).onKeyUp (keyCode , event );
49
+ }
50
+ return handled || super .onKeyUp (keyCode , event );
51
+ }
32
52
}
You can’t perform that action at this time.
0 commit comments