[TIMOB-26248] Hyperloop: Android - Cannot use android.provider.MediaStore.Images.Media API
| GitHub Issue | n/a | 
|---|---|
| Type | Bug | 
| Priority | Critical | 
| Status | Closed | 
| Resolution | Fixed | 
| Resolution Date | 2020-05-01T20:36:41.000+0000 | 
| Affected Version/s | n/a | 
| Fix Version/s | n/a | 
| Components | Hyperloop | 
| Labels | engReviewed, hyperloop | 
| Reporter | Donald Anderson | 
| Assignee | Joshua Quick | 
| Created | 2018-07-31T11:14:06.000+0000 | 
| Updated | 2020-05-01T20:36:41.000+0000 | 
Description
	If I create a new project and add 
var mediastore = require('android.provider.MediaStore.Images.Media');
Requested module not found: android.provider.MediaStore.Images.Media
Attachments
| File | Date | Size | 
|---|---|---|
| Android MediaStore.Images.Media logs | 2018-07-31T11:13:35.000+0000 | 362871 | 
What if you only require
android.provider.MediaStoreand accessImages.Mediafrom the result? e.g.var MediaStore = require('android.provider.MediaStore'); var DATE_ADDED = MediaStore.Images.Media.DATE_ADDED;MediaStorebeing required, it's sub-constants are accessed via it then.I can't seem to get at the media sub-class. if I use this.
var mediastore = require('android.provider.MediaStore'); console.log("1:", mediastore.Images); console.log("2:", mediastore.Images.Media);[INFO] : 1: function () { [INFO] : var result; [INFO] : // Allow the constructor to either invoke the real java constructor, or function as a "wrapping" method that will take [INFO] : // a single argument that is a native hyperloop proxy for this class type and just wraps it in our JS type. [INFO] : if (arguments.length == 1 && arguments[0].isNativeProxy && arguments[0].isInstanceProxy && arguments[0].isInstanceOf('android.provider.MediaStore$Images')) { [INFO] : result = arguments[0]; [INFO] : } [INFO] : else { [INFO] : result = Images.class.newInstance(arguments); [INFO] : } [INFO] : [INFO] : this.$native = result; [INFO] : this._hasPointer = result != null; [INFO] : this._private = {}; [INFO] : } [INFO] : 2: undefinedvar Images = require('android.provider.MediaStore.Images'); console.log("1:", Images); console.log("2:", Images.Media);[INFO] : 1: function () { [INFO] : var result; [INFO] : // Allow the constructor to either invoke the real java constructor, or function as a "wrapping" method that will take [INFO] : // a single argument that is a native hyperloop proxy for this class type and just wraps it in our JS type. [INFO] : if (arguments.length == 1 && arguments[0].isNativeProxy && arguments[0].isInstanceProxy && arguments[0].isInstanceOf('android.provider.MediaStore$Images')) { [INFO] : result = arguments[0]; [INFO] : } [INFO] : else { [INFO] : result = Images.class.newInstance(arguments); [INFO] : } [INFO] : [INFO] : this.$native = result; [INFO] : this._hasPointer = result != null; [INFO] : this._private = {}; [INFO] : } [INFO] : 2: undefinedThen it might indeed be a bug. [~jquick] [~gmathews] do you know more?
This appears to be a Hyperloop limitation. The
Mediaclass withinandroid.provider.MediaStore$Images$Mediais an inner class within anotherImagesinner class. Hyperloop can access the 1st inner class, but not an inner class within another inner class. I can successfully require it in Hyperloop using the dollar sign'$'version above, but Hyperloop will fail to provide the static constants/methods. So, it doesn't solve anything. You can work-around this issue for now by using Google'sContentResolverclass instead, which is what theMediaclass uses internally. Have a look at Google's code here... [MediaStore.java#L861](https://github.com/aosp-mirror/platform_frameworks_base/blob/master/core/java/android/provider/MediaStore.java#L861) And theirContentResolverclass documentation can be found here... https://developer.android.com/reference/android/content/ContentResolverThis was resolved as of Titanium 9.0.0 via ticket [TIMOB-27298].