QtAndroid 名稱空間提供輔助 Android 開發的各種功能。 更多...
| 頭: | #include <QtAndroid> |
| qmake: | QT += androidextras |
| Since: | Qt 5.3 |
該名稱空間在 Qt 5.3 引入。
| 枚舉類 | BindFlag { None, AutoCreate, DebugUnbind, NotForeground, AboveClient, …, ExternalService } |
| flags | BindFlags |
| 枚舉類 | PermissionResult { Granted, Denied } |
| typedef | PermissionResultCallback |
| typedef | PermissionResultMap |
| typedef | Runnable |
| QAndroidJniObject | androidActivity () |
| QAndroidJniObject | androidContext () |
| int | androidSdkVersion () |
| QAndroidJniObject | androidService () |
| bool | bindService (const QAndroidIntent & serviceIntent , const QAndroidServiceConnection & serviceConnection , QtAndroid::BindFlags flags = BindFlag::None) |
| QtAndroid::PermissionResult | checkPermission (const QString & permission ) |
| void | hideSplashScreen () |
| void | hideSplashScreen (int duration ) |
| void | requestPermissions (const QStringList & permissions , const QtAndroid::PermissionResultCallback & callbackFunc ) |
| QtAndroid::PermissionResultMap | requestPermissionsSync (const QStringList & permissions , int timeoutMs = INT_MAX) |
| void | runOnAndroidThread (const QtAndroid::Runnable & runnable ) |
| void | runOnAndroidThreadSync (const QtAndroid::Runnable & runnable , int timeoutMs = INT_MAX) |
| bool | shouldShowRequestPermissionRationale (const QString & permission ) |
| void | startActivity (const QAndroidJniObject & intent , int receiverRequestCode , QAndroidActivityResultReceiver * resultReceiver = nullptr) |
| void | startActivity (const QAndroidIntent & intent , int receiverRequestCode , QAndroidActivityResultReceiver * resultReceiver = nullptr) |
| void | startActivity (const QAndroidJniObject & intent , int receiverRequestCode , std::function<void (int, int, const QAndroidJniObject &)> callbackFunc ) |
| void | startIntentSender (const QAndroidJniObject & intentSender , int receiverRequestCode , QAndroidActivityResultReceiver * resultReceiver = nullptr) |
此枚舉用於 QtAndroid::bindService 以描述履行綁定的模式。
| 常量 | 值 | 描述 |
|---|---|---|
QtAndroid::BindFlag::None
|
0x00000000
|
沒有選項。 |
QtAndroid::BindFlag::AutoCreate
|
0x00000001
|
自動創建服務,隻要綁定存在。見 BIND_AUTO_CREATE 文檔編製瞭解更多細節。 |
QtAndroid::BindFlag::DebugUnbind
|
0x00000002
|
包括用於取消不匹配調用綁定的調試幫助。見 BIND_DEBUG_UNBIND 文檔編製瞭解更多細節。 |
QtAndroid::BindFlag::NotForeground
|
0x00000004
|
Don't allow this binding to raise the target service's process to the foreground scheduling priority. See BIND_NOT_FOREGROUND 文檔編製瞭解更多細節。 |
QtAndroid::BindFlag::AboveClient
|
0x00000008
|
Indicates that the client application binding to this service considers the service to be more important than the app itself. See BIND_ABOVE_CLIENT 文檔編製瞭解更多細節。 |
QtAndroid::BindFlag::AllowOomManagement
|
0x00000010
|
Allow the process hosting the bound service to go through its normal memory management. See BIND_ALLOW_OOM_MANAGEMENT 文檔編製瞭解更多細節。 |
QtAndroid::BindFlag::WaivePriority
|
0x00000020
|
Don't impact the scheduling or memory management priority of the target service's hosting process. See BIND_WAIVE_PRIORITY 文檔編製瞭解更多細節。 |
QtAndroid::BindFlag::Important
|
0x00000040
|
This service is assigned a higher priority so that it is available to the client when needed. See BIND_IMPORTANT 文檔編製瞭解更多細節。 |
QtAndroid::BindFlag::AdjustWithActivity
|
0x00000080
|
If binding from an activity, allow the target service's process importance to be raised based on whether the activity is visible to the user. See BIND_ADJUST_WITH_ACTIVITY 文檔編製瞭解更多細節。 |
QtAndroid::BindFlag::ExternalService
|
-2147483648
|
The service being bound is an isolated, external service. See BIND_EXTERNAL_SERVICE 文檔編製瞭解更多細節。 |
該枚舉在 Qt 5.10 引入或被修改。
BindFlags 類型是 typedef 對於 QFlags <BindFlag>。它存儲 BindFlag 值的 OR (或) 組閤。
此枚舉用於描述權限狀態。
| 常量 | 值 | 描述 |
|---|---|---|
QtAndroid::PermissionResult::Granted
|
0
|
權限被授予。 |
QtAndroid::PermissionResult::Denied
|
1
|
權限被拒。 |
該枚舉在 Qt 5.10 引入或被修改。
Synonym for std::function<void(const PermissionResultMap &)>.
同義詞 QHash < QString , PermissionResult >.
同義詞 std::function<void()>。
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 ().
綁定服務給齣通過 serviceIntent , serviceConnection and flags 。 serviceIntent 對象標識要連接的服務。 serviceConnection 是因啓動和停止服務,接收信息的監聽器。
返迴 true 當成功時
見 Android documentation 文檔編製瞭解更多細節。
該函數在 Qt 5.10 引入。
另請參閱 QAndroidIntent , QAndroidServiceConnection ,和 BindFlag .
Checks if the permission was granted or not. This function should be called every time when the application starts for needed permissions, as the users might disable them from Android Settings.
該函數在 Qt 5.10 引入。
立即隱藏閃屏。
該函數在 Qt 5.7 引入。
Hides the splash screen, fading it for duration 毫秒。
該函數在 Qt 5.10 引入。
Asynchronously requests permissions to be granted to this application, callbackFunc will be called with the results.
該函數在 Qt 5.10 引入。
Synchronously requests permissions to be granted to this application, waits timeoutMs to complete.
該函數在 Qt 5.10 引入。
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 引入。
返迴
true
if you should show UI with a rationale for requesting a
permission
.
該函數在 Qt 5.10 引入。
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 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.13 引入。
Starts the activity given by intent , using the request code receiverRequestCode , and provides the result by calling callbackFunc .
該函數在 Qt 5.13 引入。
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 引入。