'From Unity android app open setting panel within custom canvas view
I would like to open Unity Android application from the setting panel within the custom canvas view.
Can I get a code snippet to bring it within canvas view rather than opening over the whole window?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System.Runtime.InteropServices;
using System.IO;
using System;
public class GetSetting : MonoBehaviour
{
void Start()
{
#if UNITY_ANDROID
string bundleId = "com.android.settings";
AndroidJavaClass up = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject ca = up.GetStatic<AndroidJavaObject>("currentActivity");
AndroidJavaObject packageManager = ca.Call<AndroidJavaObject>("getPackageManager");
//if the app is installed, no errors. Else, doesn't get past next line
AndroidJavaObject launchIntent = packageManager.Call<AndroidJavaObject>("getLaunchIntentForPackage", bundleId);
launchIntent.Call<AndroidJavaObject>("addCategory", "android.intent.category.MAIN");
launchIntent.Call<AndroidJavaObject>("addCategory", "android.intent.category.HOME");
launchIntent.Call<AndroidJavaObject>("setFlags", 0x10000000);
ca.Call("startActivity", launchIntent);
up.Dispose();
ca.Dispose();
packageManager.Dispose();
launchIntent.Dispose();
#else
Debug.Log("No Toast setup for this platform.");
#endif
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|