Hey guys,
I’m having problem on scanning media, after capture screenshot from unity with Vuforia QCAR.
I manage to capture and move the file to a folder, but unable to make it appear in gallery.
I’m not familiar with NDK or programming outside Unity.
I have two (2) javascript (.js),
Screenshot.js (Assets/Scripts)
RescanMedia.js (Assets/Plugins/Android)
So my Screenshot does the usual stuff,
Application.CaptureScreenshot(“file.png”);
check for file existent on Application.persistentDataPath
move to a folder (mnt/sdcard/Pictures/ABC)
RescanMedia.ScanNow(“file://mnt/sdcard/Pictures/ABC/file.png”);
This is the RescanMedia.js
#pragma strict
#if UNITY_ANDROID
static function ScanNow(uriString : String) {
print("here1");
var uriClass = AndroidJavaClass("android.net.Uri");
print("here2");
var uri = uriClass.CallStatic.<AndroidJavaObject>("parse", uriString);
print("here3");
var intent = AndroidJavaObject("android.intent.action", "android.intent.action.media_mounted", uri);
print("here4");
var unityPlayerClass = AndroidJavaClass("com.qualcomm.QCARUnityPlayer.QCARPlayerActivity");
print("here5");
var currentActivity = unityPlayerClass.GetStatic.<AndroidJavaObject>("currentActivity");
print("here6");
currentActivity.Call("sendBroadcast", intent);
}
#endif
So basically, I’m trying to replicated this line of code to rescan my file.png
sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + Environment.getExternalStorageDirectory())));
And I get this error on logcat
.
..
...
here3
JNI ERROR (app bug): accessed stale weak global reference 0x13 (index 4 in a table of size 0)
VM aborting
...
..
.
I still using the Android manifest provided by QCAR. Do I need to make any changes in there?
If anyone have know how to make the picture appear in gallery, I would appreciate a tentative guide.
cheers,
-SIM-