I record a video in unity, I move this video to the DCIM folder in the device, but I can only see the video when I restart the device.
I guess that when I turn on my phone it scann the memory, is there a posibility to make that scann affter the video is moved?.
I saw post about using unity pluggins and using the “System.IO” but I cant figure it out how to make it work.
this looks like doing something, but its not working.
//REFRESHING THE ANDROID PHONE PHOTO GALLERY IS BEGUN
AndroidJavaClass classPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject objActivity = classPlayer.GetStatic<AndroidJavaObject>("currentActivity");
AndroidJavaClass classUri = new AndroidJavaClass("android.net.Uri");
AndroidJavaObject objIntent = new AndroidJavaObject("android.content.Intent", new object[2]{"android.intent.action.MEDIA_MOUNTED", classUri.CallStatic<AndroidJavaObject>("parse", "file://" + myScreenshotLocation)});
objActivity.Call ("sendBroadcast", objIntent);
//REFRESHING THE ANDROID PHONE PHOTO GALLERY IS COMPLETE
this is also a code from this question but it doesnt work for me
NOTE: This plugin will refresh the gallery and open it. It is assumed you have already saved the screenshot or image prior to this.
Accessing the gallery from Unity alone can’t be done, but using an IDE medium like android studio or Eclipse can. Unity just doesn’t have the correct API. So if you open up android studio and create a plugin, there’s very little you have to do in unity. Use this link to see a tutorial about making plugins:
Now, you can make your own plugin, or just use one that I made:
I used the package name of com.vexstarstruck.unity. I don’t know if it is necessary for you to do the same. If so, you could just make your own plugin. I highly recommend you learn how to make your own plugins as it will be extremely useful to use the native functions android provides.
Copy this jar file into your Assets/Plugins/Android folder. Then in Unity, when you want to call this plugin, add this code to any script after you save the image:
The reason it may not have worked for you is because you did not have the correct plugin naming, function, or package name. Either way, anyone can contact me if you need clarification or extra help.
Just change android.intent.action.MEDIA_MOUNTED into android.intent.action.MEDIA_SCANNER_SCAN_FILE, because ACTION_MEDIA_MOUNTED got locked in KitKat. Thanksfully ACTION_MEDIA_SCANNER_SCAN_FILE still works.