/
githubmr
/
facebook-react-native
Обзор
Документация
Войти
/
githubmr
/
facebook-react-native
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
main
packages/react-native/ReactCxxPlatform/react/jni/JniHelper.cpp
28 строк
925 B
Christoph Purrer
Add jni target to ReactCxxPlatform (#51898)
10 июн 2025, 05:15
10 июн 2025, 05:15
43ba9df
Код
Авторство
О чём код?
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ #include <fbjni/Context.h> #include <fbjni/fbjni.h> namespace facebook::react { jobject getApplication(JNIEnv* env) { auto activityThreadClass = env->FindClass("android/app/ActivityThread"); auto currentApplicationMethodID = env->GetStaticMethodID( activityThreadClass, "currentApplication", "()Landroid/app/Application;"); return env->CallStaticObjectMethod( activityThreadClass, currentApplicationMethodID); } jni::alias_ref<jni::AContext> getContext() { auto env = facebook::jni::Environment::ensureCurrentThreadIsAttached(); auto application = getApplication(env); return facebook::jni::wrap_alias( static_cast<facebook::jni::AContext::javaobject>(application)); } } // namespace facebook::react