コード例 #1
0
        public void onRequestCompletedwithObject(AndroidJavaObject resultObject)
        {
            //Log.i(LOG_TAG, "unity callback with result object");
            if (mCallback == null)
            {
                // Log.w(LOG_TAG, "unity callback but user callback is null ");
            }

            List <WVR_RequestResult> permissionResults = new List <WVR_RequestResult>();

            bool[]            resultArray = null;
            AndroidJavaObject boolbuffer  = resultObject.Get <AndroidJavaObject>("result");

            if ((boolbuffer) != null && (boolbuffer.GetRawObject() != IntPtr.Zero))
            {
                try
                {
        #if UNITY_2018
                    resultArray = AndroidJNI.FromBooleanArray(boolbuffer.GetRawObject());
        #else
                    resultArray = AndroidJNIHelper.ConvertFromJNIArray <bool[]>(boolbuffer.GetRawObject());
        #endif
                    //  Log.i(LOG_TAG, "ConvertFromJNIArray to bool array : " + resultArray.Length);
                }
                catch (Exception)
                {
                    //  Log.e(LOG_TAG, "ConvertFromJNIArray failed: " + e.ToString());
                }
            }

            string[] permissionArray = null;

            AndroidJavaObject stringbuffer = resultObject.Get <AndroidJavaObject>("requestPermissions");
            if ((stringbuffer) != null && (stringbuffer.GetRawObject() != IntPtr.Zero))
            {
                permissionArray = AndroidJNIHelper.ConvertFromJNIArray <string[]>(stringbuffer.GetRawObject());
                // Log.i(LOG_TAG, "ConvertFromJNIArray to string array : " + permissionArray.Length);
            }

            if (permissionArray != null && resultArray != null)
            {
                for (int i = 0; i < permissionArray.Length; i++)
                {
                    WVR_RequestResult rr;
                    rr.mPermission = permissionArray[i];
                    rr.mGranted    = resultArray[i];
                    permissionResults.Add(rr);
                }
            }

            mCallback(permissionResults);
        }