import * as app from 'tns-core-modules/application'
let VibrationEffect = android.os.VibrationEffect
let v = app.android.context.getSystemService(
android.content.Context.VIBRATOR_SERVICE
)
v.vibrate(
VibrationEffect.createOneShot(
500,
VibrationEffect.DEFAULT_AMPLITUDE
)
)import android.os.Vibrator;
Vibrator v = (Vibrator) getSystemService(
Context.VIBRATOR_SERVICE
);
v.vibrate(
VibrationEffect.createOneShot(
500,
VibrationEffect.DEFAULT_AMPLITUDE
)
);const LinearLayout = android.widget.LinearLayout;
const LayoutParams = android.widget.LinearLayout.LayoutParams;
const TextView = android.widget.TextView;
const Button = android.widget.Button;
const Gravity = android.view.Gravity;
@JavaProxy("my.application.name.MainActivity");
class MainActivity extends android.app.Activity {
constructor() {
super();
return global.__native(this);
}
onCreate: function (savedInstanceState) {
super.onCreate(savedInstance);
let linLayout = new LinearLayout(this);
linLayout.setOrientation(LinearLayout.VERTICAL);
let linLayoutParam = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
setContentView(linLayout, linLayoutParam);
let lpView = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
let tv = new TextView(this);
tv.setText("TextView");
tv.setLayoutParams(lpView);
linLayout.addView(tv);
}
});Can I invoke "xxx" method?
public class VibrationModule extends ReactContextBaseJavaModule {
ReactApplicationContext reactContext;
public VibrationModule(ReactApplicationContext reactContext) {
super(reactContext);
this.reactContext = reactContext;
}
@Override
public String getName() {
return "VibrationAndroid";
}
@ReactMethod
public void vibrate(int duration) {
Vibrator v = (Vibrator) reactContext.getSystemService(
Context.VIBRATOR_SERVICE);
if (v == null) return;
v.vibrate(duration);
}
}var Vibration = require('react-native-vibration')
Vibration.vibrate(500)Props
Layout
Callback
Flutter VM
Dart VM
Skia
Widgets
(UI, Layout, Animation, Gestures, etc...)
Native Platform
Dart
Main
(Native)
GPU
(Skia)
IO
Native api invoke
Render
invoke
Heavey
IO