The QtAndroid namespace provides miscellaneous functions to aid Android development. 更多...
| 頭: | #include <QtAndroid> |
| qmake: | QT += androidextras |
| Since: | Qt 5.3 |
| typedef | Runnable |
| QAndroidJniObject | androidActivity () |
| QAndroidJniObject | androidContext () |
| int | androidSdkVersion () |
| QAndroidJniObject | androidService () |
| void | hideSplashScreen () |
| void | runOnAndroidThread (const Runnable & runnable ) |
| void | runOnAndroidThreadSync (const Runnable & runnable , int timeoutMs = INT_MAX) |
| void | startActivity (const QAndroidJniObject & intent , int receiverRequestCode , QAndroidActivityResultReceiver * resultReceiver = nullptr) |
| void | startIntentSender (const QAndroidJniObject & intentSender , int receiverRequestCode , QAndroidActivityResultReceiver * resultReceiver = nullptr) |
The QtAndroid namespace provides miscellaneous functions to aid Android development.
Returns a handle to this application's main Activity
該函數在 Qt 5.3 引入。
另請參閱 QAndroidJniObject , androidService (),和 androidContext ().
Returns a handle to this application's main Context. Depending on the nature of the application the Context object is either the main Service or Activity object.
該函數在 Qt 5.8 引入。
另請參閱 QAndroidJniObject , androidActivity (),和 androidService ().
返迴 Android SDK 版本。這又稱為 API 級彆。
該函數在 Qt 5.3 引入。
Returns a handle to this application's main Service
該函數在 Qt 5.7 引入。
另請參閱 QAndroidJniObject , androidActivity (),和 androidContext ().
Hides the splash screen.
該函數在 Qt 5.7 引入。
Posts the given runnable on the android thread. The runnable will be queued and executed on the Android UI thread, unless it called on the Android UI thread, in which case the runnable will be executed immediately.
This function is useful to set asynchronously properties of objects that must be set on on Android UI thread.
該函數在 Qt 5.7 引入。
Posts the runnable on the Android UI thread and waits until the runnable is executed, or until timeoutMs has passed
This function is useful to create objects, or get properties on Android UI thread:
QAndroidJniObject javaControl; QtAndroid::runOnAndroidThreadSync([&javaControl](){ // create our Java control on Android UI thread. javaControl = QAndroidJniObject("android/webkit/WebView", "(Landroid/content/Context;)V", QtAndroid::androidActivity().object<jobject>()); javaControl.callMethod<void>("setWebViewClient", "(Landroid/webkit/WebViewClient;)V", QAndroidJniObject("android/webkit/WebViewClient").object()); }); // Continue the execution normally qDebug() << javaControl.isValid();
該函數在 Qt 5.7 引入。
Starts the activity given by intent and provides the result asynchronously through the resultReceiver if this is non-null.
若
resultReceiver
為 null,那麼
startActivity()
方法在
androidActivity()
將被調用。否則
startActivityForResult()
將被調用。
The receiverRequestCode is a request code unique to the resultReceiver , and will be returned along with the result, making it possible to use the same receiver for more than one intent.
該函數在 Qt 5.3 引入。
Starts the activity given by intentSender and provides the result asynchronously through the resultReceiver if this is non-null.
若
resultReceiver
為 null,那麼
startIntentSender()
方法在
androidActivity()
將被調用。否則
startIntentSenderForResult()
將被調用。
The receiverRequestCode is a request code unique to the resultReceiver , and will be returned along with the result, making it possible to use the same receiver for more than one intent.
該函數在 Qt 5.3 引入。