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
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 Dictionary<string, string> ParseApplicationArguments()
31 {
32 AndroidJavaClass unityPlayerClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
33
34 AndroidJavaObject currentActivity = unityPlayerClass.GetStatic<AndroidJavaObject>("currentActivity");
35
36 AndroidJavaObject intent = currentActivity.Call<AndroidJavaObject>("getIntent");
37
38 string urlData = intent.Call<string>("getDataString");
39
40 string optionalParameter = "", returnTargetParameter = "", targetTypeParameter = "", pixotoken = "";
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 Dictionary<string, string> parameters = new Dictionary<string, string>();
59
60 if (!string.IsNullOrEmpty(optionalParameter))
61 {
62 parameters.Add("optional", optionalParameter);
63 }
64
65 if (!string.IsNullOrEmpty(returnTargetParameter))
66 {
67 parameters.Add("returntarget", returnTargetParameter);
68 }
69
70 if (!string.IsNullOrEmpty(targetTypeParameter))
71 {
72 parameters.Add("targettype", targetTypeParameter);
73 }
74
75 if (!string.IsNullOrEmpty(pixotoken))
76 {
77 parameters.Add("pixotoken", pixotoken);
78 }
79
80 return parameters;
81 }
82 }
83}
UnityEngine.Debug UDebug
override bool OpenApplication(string applicationPath, string[] argumentKeys, string[] argumentValues)
override Dictionary< string, string > ParseApplicationArguments()
static bool LaunchUrl(string url)
static bool LaunchApp(string packageName, string[] extraKeys, string[] extraValues)
virtual Dictionary< string, string > ParseURLArguments(string url)