Access the current android activity

时光毁灭记忆、已成空白 提交于 2020-01-03 04:09:06

问题


How can I access the current Android activity class?

I am using the necessitas framework (QT in Android). Basically, using the Android NDK an activity calls a QT application (.so). All runs fine. Now I am working on some bindings to access the GPS from the QT application. From some java examples that access the GPS I saw that the most vital part is to allow access to the GPS service:

LocationManager lm; lm = (LocationManager) getSystemService(LOCATION_SERVICE);

Here getSystemService is a method of class activity. Because I am using the JNI inside the QT application I need to access the current activity that is running my QT application, so I can call the function getSystemService.

So the question is. How do I get the current activity where my QT application is running from?


回答1:


I solved this by passing the current application (running my QT application) to my QT application using JNI's RegisterNatives().

Carlos.



来源:https://stackoverflow.com/questions/5992845/access-the-current-android-activity

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!