MCPcopy Create free account
hub / github.com/android/ndk-samples / GetDisplayRotation

Method GetDisplayRotation

camera/basic/src/main/cpp/camera_ui.cpp:28–45  ·  view source on GitHub ↗

* Retrieve current rotation from Java side * * @return current rotation angle */

Source from the content-addressed store, hash-verified

26 * @return current rotation angle
27 */
28int CameraEngine::GetDisplayRotation() {
29 ASSERT(app_, "Application is not initialized");
30
31 JNIEnv* env;
32 ANativeActivity* activity = app_->activity;
33 activity->vm->GetEnv((void**)&env, JNI_VERSION_1_6);
34
35 activity->vm->AttachCurrentThread(&env, NULL);
36
37 jobject activityObj = env->NewGlobalRef(activity->clazz);
38 jclass clz = env->GetObjectClass(activityObj);
39 jint newOrientation = env->CallIntMethod(
40 activityObj, env->GetMethodID(clz, "getRotationDegree", "()I"));
41 env->DeleteGlobalRef(activityObj);
42
43 activity->vm->DetachCurrentThread();
44 return newOrientation;
45}
46
47/**
48 * Initializate UI on Java side. The 2 seekBars' values are passed in

Callers

nothing calls this directly

Calls 3

AttachCurrentThreadMethod · 0.80
CallIntMethodMethod · 0.80
DetachCurrentThreadMethod · 0.80

Tested by

no test coverage detected