| 60 | } |
| 61 | |
| 62 | void mediaScannerScanFile(const QString& path) |
| 63 | { |
| 64 | static const auto ACTION_MEDIA_SCANNER_SCAN_FILE = |
| 65 | QAndroidJniObject::getStaticObjectField<jstring>("android/content/Intent", |
| 66 | "ACTION_MEDIA_SCANNER_SCAN_FILE"); |
| 67 | auto intent = QAndroidJniObject { "android/content/Intent", |
| 68 | "(Ljava/lang/String;)V", |
| 69 | ACTION_MEDIA_SCANNER_SCAN_FILE.object<jstring>() }; |
| 70 | auto file = QAndroidJniObject { "java/io/File", |
| 71 | "(Ljava/lang/String;)V", |
| 72 | QAndroidJniObject::fromString(path).object<jstring>() }; |
| 73 | auto uri = QAndroidJniObject::callStaticObjectMethod( |
| 74 | "android/net/Uri", |
| 75 | "fromFile", |
| 76 | "(Ljava/io/File;)Landroid/net/Uri;", |
| 77 | file.object()); |
| 78 | |
| 79 | intent.callObjectMethod("setData", |
| 80 | "(Landroid/net/Uri;)Landroid/content/Intent;", |
| 81 | uri.object()); |
| 82 | auto activity = QtAndroid::androidActivity(); |
| 83 | auto context = activity.callObjectMethod( |
| 84 | "getApplicationContext", |
| 85 | "()Landroid/content/Context;"); |
| 86 | context.callMethod<void>("sendBroadcast", "(Landroid/content/Intent;)V", intent.object()); |
| 87 | } |
| 88 | |
| 89 | /** |
| 90 | * Returns writable application-specific directories on all external storage volumes. |
no test coverage detected