npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-use-native

v1.0.4

Published

test

Downloads

3

Readme

react-native-use-native

A tool to use native code by JavaScript. Only some Android classes are now supported.

Updates

Now lastest version is: 1.0.4 Since version 1.0.3, $app is an ReactApplicationContext class Object, $appnative is a Context class Object. But, you only use string $appnative. Start from version 1.0.4, you can use $appnative.

Version 1.0.3 Updates

Mainly Update:

  1. Since version 1.0.3, the non-basic type will return the internal name(such as $3) not string Refrence Type.
  2. Support Array and List.
  3. Support the Boolean values.

Requirements

react-native == 0.70

The lower version and greater version is not tested.

Installation

npm install react-native-use-native

Usage

The basic is to use useJavaStatic method to call call static methods and use useJava() method to call non-static methods.

Method declaration

useJavaStatic(className:string,methodName:string,params:any[],packageName:string=""):Promise<string>
useJava(objectName:string,methodName:string,params:any[]):Promise<string>

In useJavaStatic, when packageName=="", the className must be the full name includes package name such as android.widget.Toast not Toast. Of Course, you can write Toast in className and android.widget in packageName.

An example about Toast:

import {useJavaStatic,useJava,$app} from 'react-native-use-native';
const toast=await useJavaStatic("android.widget.Toast","makeText",[$app,"HelloToast",0]);
await useJava(toast,"show",[]);

The $app refers to the ReactApplicationContext of now application. You also can directly use useJavaNative. Please see the source code to know more.

use Libraries

Some classes(such as Toast) is packaged to JavaScript/TypeScript Classes, you can directly use these classes.

import {Toast} from 'react-native-use-native';
let toast=await Toast.makeText($app,"HelloToast",Toast.LENGTH_SHORT);
await toast.show();

Create Java Object

You also can create a Java Object by using createJavaObject. You can use getJavaObjectValue to get the value of below's type:int,float,double,Integer,Float,Double and String. Else type will return the string value:Refrence Type. It only can find the object that returned in JS or created by createJavaObject.

Notes

The Java/Android packages you want to use must be imported in Java Code.

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


Made with create-react-native-library