Documentation for the Unity C# Library
Loading...
Searching...
No Matches
PixoAndroidPlatformUtilities.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using System.Data.SqlTypes;
4using System.Diagnostics;
5using System.IO;
6using System.Linq;
7using UnityEngine;
8using UDebug = UnityEngine.Debug;
9
10namespace PixoVR.Apex
11{
13 {
14 // TODO: Migrate functionality from the old PixoAndroidUtils into this class.
16 {
17 UDebug.Log($"Initializing class {GetType().Name}");
18 }
19
20 public override bool OpenURL(string url)
21 {
22 return PixoAndroidUtils.LaunchUrl(url);
23 }
24
25 public override bool OpenApplication(string applicationPath, string[] argumentKeys, string[] argumentValues)
26 {
27 return PixoAndroidUtils.LaunchApp(applicationPath, argumentKeys, argumentValues);
28 }
29
30 public override void CloseCurrentApplication()
31 {
32 PixoAndroidUtils.CurrentActivity.Call("finishAndRemoveTask");
33 }
34
35 public override Dictionary<string, string> ParseApplicationArguments()
36 {
37 string optionalParameter = "", returnTargetParameter = "", targetTypeParameter = "", pixotoken = "";
38 using (AndroidJavaObject intent = PixoAndroidUtils.CurrentActivity.Call<AndroidJavaObject>("getIntent"))
39 {
40 string urlData = intent.Call<string>("getDataString");
41
42 UDebug.Log("[PixoAndroidPlatformUtilities] Parsed Passed Data.");
43 if(urlData != null && urlData.Length > 0)
44 {
45 UDebug.Log("[PixoAndroidPlatformUtilities] Parse from URL.");
46 return ParseURLArguments(urlData);
47 }
48 else
49 {
50 // TODO: Loop through ALL extras and return them
51 UDebug.Log("[PixoAndroidPlatformUtilities] Parsing from extras.");
52 optionalParameter = intent.Call<string>("getStringExtra", "optional");
53 returnTargetParameter = intent.Call<string>("getStringExtra", "returntarget");
54 targetTypeParameter = intent.Call<string>("getStringExtra", "targettype");
55 pixotoken = intent.Call<string>("getStringExtra", "pixotoken");
56 }
57 }
58
59 Dictionary<string, string> parameters = new Dictionary<string, string>();
60
61 if (!string.IsNullOrEmpty(optionalParameter))
62 {
63 parameters.Add("optional", optionalParameter);
64 }
65
66 if (!string.IsNullOrEmpty(returnTargetParameter))
67 {
68 parameters.Add("returntarget", returnTargetParameter);
69 }
70
71 if (!string.IsNullOrEmpty(targetTypeParameter))
72 {
73 parameters.Add("targettype", targetTypeParameter);
74 }
75
76 if (!string.IsNullOrEmpty(pixotoken))
77 {
78 parameters.Add("pixotoken", pixotoken);
79 }
80
81 return parameters;
82 }
83 }
84}
UnityEngine.Debug UDebug
override bool OpenApplication(string applicationPath, string[] argumentKeys, string[] argumentValues)
override Dictionary< string, string > ParseApplicationArguments()
static AndroidJavaObject CurrentActivity
JNI to call com.unity.player.UnityPlayer.currentActivity()
static bool LaunchUrl(string url)
static bool LaunchApp(string packageName, string[] extraKeys, string[] extraValues)
virtual Dictionary< string, string > ParseURLArguments(string url)