- Home /
how to reward the player after they install another game and how to check if they did install ? (Android)
I want to give the player the possibility to install another one of my games in exchange for receiving some rewards in the current game they were playing, i don't know how to make sure they installed it and that they didn't just visit the game's page in the play store store. Any ideas ? Even making sure they gave a 5 stars rating is an acceptable solution.
Answer by SohailBukhari · Mar 28, 2017 at 07:47 AM
There is easy solution for checking that user installed your other app or not. Simply check the bundle name of your app in the mobile if result returns true the give whatever you want.
private bool checkPackageAppIsPresent (string package)
{
AndroidJavaClass up = new AndroidJavaClass ("com.unity3d.player.UnityPlayer");
AndroidJavaObject ca = up.GetStatic<AndroidJavaObject> ("currentActivity");
AndroidJavaObject packageManager = ca.Call<AndroidJavaObject> ("getPackageManager");
AndroidJavaObject appList = packageManager.Call<AndroidJavaObject> ("getInstalledPackages", 0);
int num = appList.Call<int> ("size");
for (int i = 0; i < num; i++) {
AndroidJavaObject appInfo = appList.Call<AndroidJavaObject> ("get", i);
string packageNew = appInfo.Get<string> ("packageName");
if (packageNew.CompareTo (package) == 0) {
return true;
}
}
return false;
}
Your answer
Follow this Question
Related Questions
UI works in editor, but not on mobile device 1 Answer
Moving an object in Unity3d for Android 0 Answers
How to scale different GUI objects to fit screen size ANDROID 1 Answer
Programmatically changing brightness setting on Android using c# 0 Answers
Android: After the third touch all touches get cancelled 1 Answer