本文整理汇总了Java中com.facebook.react.modules.core.RCTNativeAppEventEmitter类的典型用法代码示例。如果您正苦于以下问题:Java RCTNativeAppEventEmitter类的具体用法?Java RCTNativeAppEventEmitter怎么用?Java RCTNativeAppEventEmitter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RCTNativeAppEventEmitter类属于com.facebook.react.modules.core包,在下文中一共展示了RCTNativeAppEventEmitter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createSpeechRecognizer
import com.facebook.react.modules.core.RCTNativeAppEventEmitter; //导入依赖的package包/类
@ReactMethod
public void createSpeechRecognizer(final Promise promise) {
if (reactContext == null)
throw new IllegalArgumentException("ReactApplicationContext must be defined!");
if (mSpeechRecognizer != null) {
mSpeechRecognizer.destroy();
mSpeechRecognizer = null;
}
if (SpeechRecognizer.isRecognitionAvailable(reactContext)) {
mSpeechRecognizer = SpeechRecognizer.createSpeechRecognizer(reactContext);
mSpeechRecognizer.setRecognitionListener(new SpeechRecognitionListener(
this.reactContext.getJSModule(RCTNativeAppEventEmitter.class)
));
promise.resolve(null);
} else{
promise.reject("error", "SpeechRecognizer not available");
}
}
示例2: initialize
import com.facebook.react.modules.core.RCTNativeAppEventEmitter; //导入依赖的package包/类
@ReactMethod
public void initialize() {
ReactApplication application = (ReactApplication)getReactApplicationContext()
.getCurrentActivity()
.getApplication();
DevSupportManager devSupportManager = application
.getReactNativeHost()
.getReactInstanceManager()
.getDevSupportManager();
devSupportManager.addCustomDevOption("Log AsyncStorage", new DevOptionHandler() {
@Override
public void onOptionSelected() {
getReactApplicationContext()
.getJSModule(RCTNativeAppEventEmitter.class)
.emit("LogAsyncStorage", null);
}
});
}
开发者ID:jsoendermann,项目名称:react-native-async-storage-dev-menu-item,代码行数:21,代码来源:AsyncStorageDevMenuItemModule.java
示例3: createJSModules
import com.facebook.react.modules.core.RCTNativeAppEventEmitter; //导入依赖的package包/类
@Override
public List<Class<? extends JavaScriptModule>> createJSModules() {
List<Class<? extends JavaScriptModule>> jsModules = new ArrayList<>(Arrays.asList(
DeviceEventManagerModule.RCTDeviceEventEmitter.class,
JSTimersExecution.class,
RCTEventEmitter.class,
RCTNativeAppEventEmitter.class,
AppRegistry.class,
com.facebook.react.bridge.Systrace.class,
HMRClient.class));
if (ReactBuildConfig.DEBUG) {
jsModules.add(DebugComponentOwnershipModule.RCTDebugComponentOwnership.class);
jsModules.add(JSCHeapCapture.HeapCapture.class);
jsModules.add(JSCSamplingProfiler.SamplingProfiler.class);
}
return jsModules;
}
示例4: ListenerMapRecognitionListener
import com.facebook.react.modules.core.RCTNativeAppEventEmitter; //导入依赖的package包/类
public ListenerMapRecognitionListener(
Set<String> enabledEvents,
RCTNativeAppEventEmitter emitter,
String eventPrefix
) {
this.enabledEvents = enabledEvents;
this.emitter = emitter;
this.eventPrefix = eventPrefix;
}
开发者ID:de-code,项目名称:react-native-android-speech-recognizer,代码行数:10,代码来源:ListenerMapRecognitionListener.java
示例5: doCreateSpeechRecognizer
import com.facebook.react.modules.core.RCTNativeAppEventEmitter; //导入依赖的package包/类
private void doCreateSpeechRecognizer(final Promise promise) {
this.speechRecognizer = SpeechRecognizer.createSpeechRecognizer(this.reactContext);
this.speechRecognizer.setRecognitionListener(new ListenerMapRecognitionListener(
this.enabledEvents,
this.reactContext.getJSModule(RCTNativeAppEventEmitter.class),
this.eventPrefix
));
promise.resolve(null);
}
开发者ID:de-code,项目名称:react-native-android-speech-recognizer,代码行数:10,代码来源:RNAndroidSpeechRecognizerModule.java
示例6: sendEvent
import com.facebook.react.modules.core.RCTNativeAppEventEmitter; //导入依赖的package包/类
public void sendEvent(String eventName,
@Nullable WritableMap params) {
if(reactContext!=null)
getReactApplicationContext()
.getJSModule(RCTNativeAppEventEmitter.class)
.emit(eventName, params);
}
示例7: sendEvent
import com.facebook.react.modules.core.RCTNativeAppEventEmitter; //导入依赖的package包/类
private void sendEvent(String eventName, @Nullable WritableMap params) {
if(this.reactContext==null)
return;
reactContext
.getJSModule(RCTNativeAppEventEmitter.class)
.emit(eventName, params);
}
示例8: onReceive
import com.facebook.react.modules.core.RCTNativeAppEventEmitter; //导入依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
if (MPushService.ACTION_MESSAGE_RECEIVED.equals(intent.getAction())) {
byte[] bytes = intent.getByteArrayExtra(MPushService.EXTRA_PUSH_MESSAGE);
int messageId = intent.getIntExtra(MPushService.EXTRA_PUSH_MESSAGE_ID, 0);
String message = new String(bytes, Constants.UTF_8);
// Toast.makeText(context, "收到新的通知:" + message, Toast.LENGTH_SHORT).show();
if (messageId > 0) MPush.I.ack(messageId);
if (TextUtils.isEmpty(message)) return;
reactContext.getJSModule(RCTNativeAppEventEmitter.class).emit(MPUSH_EVENT_MESSAGE, message);
} else {
//reactContext.getJSModule(RCTNativeAppEventEmitter.class).emit(MPUSH_EVENT, intent.getAction());
}
Log.d("MPush", intent.toString());
if (MPushService.ACTION_KICK_USER.equals(intent.getAction())) {
Toast.makeText(context, "用户被踢下线了", Toast.LENGTH_SHORT).show();
} else if (MPushService.ACTION_BIND_USER.equals(intent.getAction())) {
Toast.makeText(context, "绑定用户:"
+ intent.getStringExtra(MPushService.EXTRA_USER_ID)
+ (intent.getBooleanExtra(MPushService.EXTRA_BIND_RET, false) ? "成功" : "失败")
, Toast.LENGTH_SHORT).show();
} else if (MPushService.ACTION_UNBIND_USER.equals(intent.getAction())) {
Toast.makeText(context, "解绑用户:"
+ (intent.getBooleanExtra(MPushService.EXTRA_BIND_RET, false)
? "成功"
: "失败")
, Toast.LENGTH_SHORT).show();
} else if (MPushService.ACTION_CONNECTIVITY_CHANGE.equals(intent.getAction())) {
Toast.makeText(context, intent.getBooleanExtra(MPushService.EXTRA_CONNECT_STATE, false)
? "MPUSH连接建立成功"
: "MPUSH连接断开"
, Toast.LENGTH_SHORT).show();
} else if (MPushService.ACTION_HANDSHAKE_OK.equals(intent.getAction())) {
Toast.makeText(context, "MPUSH握手成功, 心跳:" + intent.getIntExtra(MPushService.EXTRA_HEARTBEAT, 0)
, Toast.LENGTH_SHORT).show();
}
}
示例9: sendEvent
import com.facebook.react.modules.core.RCTNativeAppEventEmitter; //导入依赖的package包/类
private void sendEvent(String eventName,
@Nullable WritableMap params) {
//ReactApplicationContext r = getReactApplicationContext();
//RCTNativeAppEventEmitter jm = r.getJSModule(RCTNativeAppEventEmitter.class);
//jm.emit(eventName, params);
//getReactApplicationContext()
this.reactContext.getJSModule(RCTNativeAppEventEmitter.class)
.emit(eventName, params);
}
示例10: getLocales
import com.facebook.react.modules.core.RCTNativeAppEventEmitter; //导入依赖的package包/类
public void getLocales() {
Intent detailsIntent = new Intent(RecognizerIntent.ACTION_GET_LANGUAGE_DETAILS);
reactContext.sendOrderedBroadcast(
detailsIntent, null,
new LocalesBroadcastReceiver(this.reactContext.getJSModule(RCTNativeAppEventEmitter.class)),
null, Activity.RESULT_OK, null, null);
}
示例11: createViewInstance
import com.facebook.react.modules.core.RCTNativeAppEventEmitter; //导入依赖的package包/类
@Override
public BarcodePicker createViewInstance(ThemedReactContext context) {
// Store event dispatcher for emission of events
eventDispatcher = context.getNativeModule(UIManagerModule.class).getEventDispatcher();
nativeAppEventEmitter = context.getJSModule(RCTNativeAppEventEmitter.class);
// BarcodePicker extends View
picker = new BarcodePicker(context, scanSettings);
// Tell picker to call our didScan method on scan
picker.setOnScanListener(this);
return picker;
}
示例12: createJSModules
import com.facebook.react.modules.core.RCTNativeAppEventEmitter; //导入依赖的package包/类
@Override
public List<Class<? extends JavaScriptModule>> createJSModules() {
return Arrays.asList(
DeviceEventManagerModule.RCTDeviceEventEmitter.class,
JSTimersExecution.class,
RCTEventEmitter.class,
RCTNativeAppEventEmitter.class,
AppRegistry.class,
com.facebook.react.bridge.Systrace.class,
HMRClient.class,
DebugComponentOwnershipModule.RCTDebugComponentOwnership.class);
}
示例13: createJSModules
import com.facebook.react.modules.core.RCTNativeAppEventEmitter; //导入依赖的package包/类
@Override
public List<Class<? extends JavaScriptModule>> createJSModules() {
return Arrays.asList(
DeviceEventManagerModule.RCTDeviceEventEmitter.class,
JSTimersExecution.class,
RCTEventEmitter.class,
RCTNativeAppEventEmitter.class,
com.facebook.react.bridge.Systrace.class,
JSCHeapCapture.HeapCapture.class
);
}
示例14: createJSModules
import com.facebook.react.modules.core.RCTNativeAppEventEmitter; //导入依赖的package包/类
@Override
public List<Class<? extends JavaScriptModule>> createJSModules() {
return Arrays.asList(
DeviceEventManagerModule.RCTDeviceEventEmitter.class,
JSTimersExecution.class,
RCTEventEmitter.class,
RCTNativeAppEventEmitter.class,
AppRegistry.class,
com.facebook.react.bridge.Systrace.class,
HMRClient.class,
JSCHeapCapture.HeapCapture.class,
DebugComponentOwnershipModule.RCTDebugComponentOwnership.class);
}
示例15: onActivityResult
import com.facebook.react.modules.core.RCTNativeAppEventEmitter; //导入依赖的package包/类
@Override
public void onActivityResult(Activity activity , final int requestCode, final int resultCode, final Intent data) {
if (requestCode == REQUEST_CODE_PAYMENT && resultCode == activity.RESULT_OK) {
this.handleResultData(data);
} else {
RCTNativeAppEventEmitter emitter = getReactApplicationContext().getJSModule(RCTNativeAppEventEmitter.class);
WritableMap map = Arguments.createMap();
map.putString("errMsg", "返回错误");
emitter.emit("Pingpp_Resp", map);
}
}