React Native: add snippet to mainactivity using native Android modules

I have a dedicated Android library for integrating camera features. The library provides the Fragment with all its functions. I just want to integrate this with Mainactivity in a React Native app.

I followed the link "Add fragment to interactive view"

I also looked at many tutorials . But I'm stuck in the place where we add the fragment to the Mainactivity container layout of our own React application.

Update:

React Component (JS file):

export default class MyCustomView extends Component { render() { return ( <View > { MyLayout.openBlankFragment(12345) } </View> ); } } const MyLayout = NativeModules.MyModule; 

MyModule (Java code):

 @ReactMethod private void openBlankFragment(final int viewId) { // Log.v("View Tag", "View ID: "+viewId); it prints tag 12345 UIManagerModule uiManager = getReactApplicationContext().getNativeModule(UIManagerModule.class); uiManager.addUIBlock(new UIBlock() { @Override public void execute(NativeViewHierarchyManager nativeViewHierarchyManager) { View view = nativeViewHierarchyManager.resolveView(viewId); final Activity activity = getCurrentActivity(); BlankFragment fragment = new BlankFragment(); FragmentTransaction transaction = ((MainActivity)activity).getSupportFragmentManager().beginTransaction(); transaction.add(view.getId(), fragment); transaction.commit(); } }); } 

view.getId () is not recognized. Need help here. If I set the identifier of the root activity representation, for example, "transaction.add (android.R.id.content, fragment);". His work is beautiful, and I can make my fragment. But I need to configure my fragment as a view on the React screen as a frame.

+7
android android-layout react-native android-fragmentmanager react-native-android
source share

No one has answered this question yet.

See similar questions:

8
React-native inside fragment
0
Add fragment to interactive view

or similar:

947
Android Studio: add jar as a library?
784
How to add a library project in Android Studio?
603
Best practice for instantiating a new Android snippet
586
What is the difference between React Native and React?
568
What is the difference between using constructor and getInitialState in React / React Native?
415
React Native android build failed. SDK location not found
360
Hide keyboard in response mode
303
How to record in React Native?
231
How to add icons to a React Native app
111
Android package name change in React Native

All Articles