Skip to content

Create/Get Java/Objective-C Objects in JavaScript and Run Methods #464

@xulihang

Description

@xulihang

Introduction

Hi there,

I am a B4X user and I am now trying to use React Native.

Since B4X compile its Basic-like language to Java/Objective-C, it is very easy to call Java/Objective-C objects using its JavaObject/NativeObject libraries like this:

Sub CreateScaledBitmap(Original As Bitmap, Width As Int, Height As Int) As Bitmap
  Dim bo As JavaObject
  bo.InitializeStatic("android.graphics.Bitmap")
  Dim bmp As Bitmap = bo.RunMethod("createScaledBitmap", Array As Object(Original, Width, Height, False))
  Return bmp
End Sub

With the new JSI feature (#91), I wonder if it is possible to add such a feature as well.

Details

Maybe in JS, call a native object like this:

import NativeObject from 'react-native'
let activity = NativeObject.getCurrentActivity();
let display = activity.runMethod("getDisplay");
let rotation:number = display.runMethod("getRotation");

In this way, we don't need to create a dedicated native module (#40) for some functions.

Discussion points

Add a module to call native object and run its methods in JavaScript

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions