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

Method AttachCurrentThread

teapots/common/ndk_helper/JNIHelper.h:295–305  ·  view source on GitHub ↗

* Attach current thread * In Android, the thread doesn't have to be 'Detach' current thread * as application process is only killed and VM does not shut down */

Source from the content-addressed store, hash-verified

293 * as application process is only killed and VM does not shut down
294 */
295 JNIEnv* AttachCurrentThread() {
296 JNIEnv* env;
297 if (activity_->vm->GetEnv((void**)&env, JNI_VERSION_1_4) == JNI_OK)
298 return env;
299 activity_->vm->AttachCurrentThread(&env, NULL);
300 pthread_key_t key;
301 if (pthread_key_create(&key, DetachCurrentThreadDtor) == 0) {
302 pthread_setspecific(key, (void*)activity_);
303 }
304 return env;
305 }
306
307 void DetachCurrentThread() {
308 activity_->vm->DetachCurrentThread();

Callers 15

GetDisplayRotationMethod · 0.80
EnableUIMethod · 0.80
OnPhotoTakenMethod · 0.80
SendTheReceivedDataFunction · 0.80
GetJniEnvMethod · 0.80
ShowUIMethod · 0.80
UpdateFPSMethod · 0.80
ShowUIMethod · 0.80
UpdateFPSMethod · 0.80
ShowUIMethod · 0.80
UpdateFPSMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected