Hey Guys, I'm trying to open an Intent on Android and filter the possible intents by known package names like in the solution posted here. http://regis.decamps.info/blog/2011/06/intent-to-open-twitter-client-on-android/ I am not very familiar with AndroidJavaClass and AndroidJavaObject usage, so far I can get the current activity, I can create an Intent and set the action and the type and even put the data i need into it. But i'm having trouble with the call to "packageManager.queryIntentActivities". I've tried something like this... Code (CSharp): AndroidJavaClass up = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); AndroidJavaObject ca = up.GetStatic<AndroidJavaObject>("currentActivity"); AndroidJavaObject packageManager = ca.Call<AndroidJavaObject>("getPackageManager"); AndroidJavaObject newIntent = new AndroidJavaObject("android.content.Intent"); newIntent.Call<AndroidJavaObject>("setType", "image/png"); AndroidJavaObject list = packageManager.Call<AndroidJavaObject>("queryIntentActivities", newIntent, "android.intent.category.DEFAULT"); but at run time i get an exception. AndroidJavaException: java.lang.NoSuchMethodError: no non-static method "Landroid/app/ApplicationPackageManager;.queryIntentActivities(Landroid.content.Intent;Ljava/lang/StringLjava/lang/Object;" java.lang.NoSuchMethodError: no non-static method "Landroid/app/ApplicationPackageManager;.queryIntentActivities(Landroid.content.Intent;Ljava/lang/StringLjava/lang/Object;" at com.unity3d.player.UnityPlayer.nativeRender(Native Method) at com.unity3d.player.UnityPlayer.a(Unknown Source) at com.unity3d.player.UnityPlayer$b.run(Unknown Source) at UnityEngine.AndroidJNISafe.CheckException () [0x00000] in <filename unknown>:0 at UnityEngine.AndroidJNISafe.GetMethodID (IntPtr obj, System.String name, System.String sig) [0x00000] in <filename unknown>:0 at UnityEngine._AndroidJNIHelper.GetMethodID (IntPtr jclass, System.String methodName, System.String signature, Boolean isStatic) [0x00000] in <filename unknown>:0 at UnityEngine.AndroidJNIHelper.GetMethodID (IntPtr javaClass, System.String methodName, Sy Also after i get the list i need to loop through the list and compare the results but I am not sure how to do that either. in the example java code he's using List<ResolveInfo> and I think i need to do something like this to get at the list items but i'm not sure if it will work because the error above happens before this can execute. AndroidJavaClass resolveInfoClass = new AndroidJavaClass("android.content.pm.ResolveInfo"); AndroidJavaObject resolveInfoObject = list.Get<AndroidJavaObject>(resolveInfoClass.ToString()); Any help would be appreciated.
I have also tried this approach, http://answers.unity3d.com/questions/425401/using-packagemanager-to-launchcheck-app-on-android.html but this doesn't allow me to filter the listed applications by known package names. Our business needs to know where people post, and the only way for us to do that right now is to limit where they can post.
queryIntentActivities takes an Intent and an int as parameters - not an Intent and a String. http://developer.android.com/reference/android/content/pm/PackageManager.html#queryIntentActivities(android.content.Intent, int)