fbdbdfb
-
Posts
2 -
Joined
-
Last visited
Content Type
Profiles
Forums
Gallery
Blogs
Events
Store
Downloads
Posts posted by fbdbdfb
-
-
Apk downloads normally, but when installing starts, 2d system window pops up so i can't do anything. How it can be fixed? Help please
This is installing script.
AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); AndroidJavaObject currentActivity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity"); AndroidJavaObject unityContext = currentActivity.Call<AndroidJavaObject>("getApplicationContext"); string packageName = unityContext.Call<string>("getPackageName"); string authority = packageName + ".provider"; AndroidJavaClass intentObj = new AndroidJavaClass("android.content.Intent"); string ACTION_VIEW = intentObj.GetStatic<string>("ACTION_VIEW"); AndroidJavaObject intent = new AndroidJavaObject("android.content.Intent", ACTION_VIEW); int FLAG_ACTIVITY_NEW_TASK = intentObj.GetStatic<int>("FLAG_ACTIVITY_NEW_TASK"); int FLAG_GRANT_READ_URI_PERMISSION = intentObj.GetStatic<int>("FLAG_GRANT_READ_URI_PERMISSION"); AndroidJavaObject fileObj = new AndroidJavaObject("java.io.File", apkPath); AndroidJavaClass fileProvider = new AndroidJavaClass("androidx.core.content.FileProvider"); AndroidJavaObject uri = fileProvider.CallStatic<AndroidJavaObject>("getUriForFile", unityContext, authority, fileObj); intent.Call<AndroidJavaObject>("setDataAndType", uri, "application/vnd.android.package-archive"); intent.Call<AndroidJavaObject>("addFlags", FLAG_ACTIVITY_NEW_TASK); intent.Call<AndroidJavaObject>("addFlags", FLAG_GRANT_READ_URI_PERMISSION); currentActivity.Call("startActivity", intent);
How to install apk from code?
in Developer Support
Posted
Can't do screenshot now. It's just a window on black background, that asks permission to install apk. I can't click yes/no cause controllers don't work in this mode.
I had the same problem but i solved it by using Permission Manager. In this case i need FLAG_GRANT_READ_URI_PERMISSION, so i can't use it.