| 
														
															@@ -4,7 +4,10 @@ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 {                                                       }
 
														 | 
														
														 | 
														
															 {                                                       }
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 {       Copyright (C) 2020 KngStr                       }
 
														 | 
														
														 | 
														
															 {       Copyright (C) 2020 KngStr                       }
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 {                                                       }
 
														 | 
														
														 | 
														
															 {                                                       }
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-{   Some Code from Kastri Free of DelphiWorlds, Thanks  }
 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+{   Some Code from                                      }
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+{     Kastri Free of DelphiWorlds                       }
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+{     QDAC of swish                                     }
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+{   Thanks                                              }
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 {                                                       }
 
														 | 
														
														 | 
														
															 {                                                       }
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 {*******************************************************}
 
														 | 
														
														 | 
														
															 {*******************************************************}
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
 
														 | 
														
														 | 
														
															 
 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -21,6 +24,7 @@ type 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   private
 
														 | 
														
														 | 
														
															   private
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     class function GetJActivity: JActivity; static;
 
														 | 
														
														 | 
														
															     class function GetJActivity: JActivity; static;
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     class function GetJContext: JContext; static;
 
														 | 
														
														 | 
														
															     class function GetJContext: JContext; static;
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    class function GetJActivityManager: JActivityManager; static;
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   public
 
														 | 
														
														 | 
														
															   public
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     const
 
														 | 
														
														 | 
														
															     const
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															       ICE_CREAM_SANDWICH = 14;
 
														 | 
														
														 | 
														
															       ICE_CREAM_SANDWICH = 14;
 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -90,20 +94,46 @@ type 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     /// <summary>Returns Java Application Activity</summary>
 
														 | 
														
														 | 
														
															     /// <summary>Returns Java Application Activity</summary>
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     /// <remarks>An exception will be launched if there is no activity, for example a Service</remarks>
 
														 | 
														
														 | 
														
															     /// <remarks>An exception will be launched if there is no activity, for example a Service</remarks>
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     class property Activity: JActivity read GetJActivity;
 
														 | 
														
														 | 
														
															     class property Activity: JActivity read GetJActivity;
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    /// <summary>Returns Java Application Activity Manager</summary>
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    class property ActivityManager: JActivityManager read GetJActivityManager;
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    /// <remarks>Need reorder tasks permission</remarks>
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    class procedure BringAppToFront; static;
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    /// <remarks>Need reorder tasks permission</remarks>
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    class procedure SendAppToBack; static;
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    /// <summary>Call a Java Activity</summary>
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    class function StartActivity(Intent: JIntent; const Code: Integer = -1): Boolean; static;
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
 
														 | 
														
														 | 
														
															 
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     /// <summary>Returns Application package name</summary>
 
														 | 
														
														 | 
														
															     /// <summary>Returns Application package name</summary>
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     class function GetPackageName: string; static;
 
														 | 
														
														 | 
														
															     class function GetPackageName: string; static;
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    /// <summary>Checks if there is at least one application capable of receiving the intent.</summary>
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    class function HasAssocApp(const URI: string): Boolean; overload; static;
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    /// <summary>Checks if there is at least one application capable of receiving the intent.</summary>
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    class function HasAssocApp(const Intent: JIntent): Boolean; overload; static;
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    /// <summary>Check if an application is installed</summary>
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    class function IsAppInstalled(const APackage: string): Boolean; static;
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    /// <summary>Add/Cear FLAG_KEEP_SCREEN_ON</summary>
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    class function KeepScreen(AOn: Boolean): Boolean; static;
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   end;
 
														 | 
														
														 | 
														
															   end;
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
 
														 | 
														
														 | 
														
															 
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 implementation
 
														 | 
														
														 | 
														
															 implementation
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
 
														 | 
														
														 | 
														
															 
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 uses
 
														 | 
														
														 | 
														
															 uses
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-  Androidapi.Helpers,
 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+  Androidapi.Helpers, Androidapi.JNIBridge,
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   Androidapi.JNI.Os, Androidapi.JNI.Support,
 
														 | 
														
														 | 
														
															   Androidapi.JNI.Os, Androidapi.JNI.Support,
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-  Androidapi.JNI.Media, Androidapi.JNI.Provider;
 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+  Androidapi.JNI.Media, Androidapi.JNI.Provider,
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+  FMX.Helpers.Android;
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
 
														 | 
														
														 | 
														
															 
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 { TAndroidHelperEx }
 
														 | 
														
														 | 
														
															 { TAndroidHelperEx }
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
 
														 | 
														
														 | 
														
															 
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+class procedure TAndroidHelperEx.BringAppToFront;
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+begin
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+  ActivityManager.moveTaskToFront(Activity.getTaskId, TJIntent.JavaClass.FLAG_ACTIVITY_NEW_TASK);
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+end;
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 class function TAndroidHelperEx.CheckBuildAndTarget(const AValue: Integer): Boolean;
 
														 | 
														
														 | 
														
															 class function TAndroidHelperEx.CheckBuildAndTarget(const AValue: Integer): Boolean;
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 begin
 
														 | 
														
														 | 
														
															 begin
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   Result := (GetBuildSdkVersion >= AValue) and (GetTargetSdkVersion >= AValue);
 
														 | 
														
														 | 
														
															   Result := (GetBuildSdkVersion >= AValue) and (GetTargetSdkVersion >= AValue);
 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -116,12 +146,12 @@ end; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
 
														 | 
														
														 | 
														
															 
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 class function TAndroidHelperEx.GetClass(const APackageClassName: string): Jlang_Class;
 
														 | 
														
														 | 
														
															 class function TAndroidHelperEx.GetClass(const APackageClassName: string): Jlang_Class;
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 begin
 
														 | 
														
														 | 
														
															 begin
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-  Result := TJLang_Class.JavaClass.forName(StringToJString(APackageClassName), True, TAndroidHelper.Context.getClassLoader);
 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+  Result := TJLang_Class.JavaClass.forName(StringToJString(APackageClassName), True, Context.getClassLoader);
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 end;
 
														 | 
														
														 | 
														
															 end;
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
 
														 | 
														
														 | 
														
															 
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 class function TAndroidHelperEx.GetDefaultIconID: Integer;
 
														 | 
														
														 | 
														
															 class function TAndroidHelperEx.GetDefaultIconID: Integer;
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 begin
 
														 | 
														
														 | 
														
															 begin
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-  Result := TAndroidHelper.Context.getApplicationInfo.icon;
 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+  Result := Context.getApplicationInfo.icon;
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 end;
 
														 | 
														
														 | 
														
															 end;
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
 
														 | 
														
														 | 
														
															 
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 class function TAndroidHelperEx.GetDefaultNotificationSound: Jnet_Uri;
 
														 | 
														
														 | 
														
															 class function TAndroidHelperEx.GetDefaultNotificationSound: Jnet_Uri;
 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -139,6 +169,14 @@ begin 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 {$ENDIF}
 
														 | 
														
														 | 
														
															 {$ENDIF}
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 end;
 
														 | 
														
														 | 
														
															 end;
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
 
														 | 
														
														 | 
														
															 
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+class function TAndroidHelperEx.GetJActivityManager: JActivityManager;
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+var
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+  AService: JObject;
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+begin
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+  AService := Context.getSystemService(TJContext.JavaClass.ACTIVITY_SERVICE);
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+  Result := TJActivityManager.Wrap((AService as ILocalObject).GetObjectID);
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+end;
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 class function TAndroidHelperEx.GetJContext: JContext;
 
														 | 
														
														 | 
														
															 class function TAndroidHelperEx.GetJContext: JContext;
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 begin
 
														 | 
														
														 | 
														
															 begin
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   Result :=
 
														 | 
														
														 | 
														
															   Result :=
 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -158,10 +196,27 @@ class function TAndroidHelperEx.GetTargetSdkVersion: Integer; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 var
 
														 | 
														
														 | 
														
															 var
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   LApplicationInfo: JApplicationInfo;
 
														 | 
														
														 | 
														
															   LApplicationInfo: JApplicationInfo;
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 begin
 
														 | 
														
														 | 
														
															 begin
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-  LApplicationInfo := TAndroidHelper.Context.getPackageManager.getApplicationInfo(TAndroidHelper.Context.getPackageName, 0);
 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+  LApplicationInfo := Context.getPackageManager.getApplicationInfo(Context.getPackageName, 0);
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   Result := LApplicationInfo.targetSdkVersion;
 
														 | 
														
														 | 
														
															   Result := LApplicationInfo.targetSdkVersion;
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 end;
 
														 | 
														
														 | 
														
															 end;
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
 
														 | 
														
														 | 
														
															 
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+class function TAndroidHelperEx.HasAssocApp(const Intent: JIntent): Boolean;
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+begin
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+  Result :=  TAndroidHelper.Activity.getPackageManager.queryIntentActivities(
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    Intent, TJPackageManager.JavaClass.MATCH_DEFAULT_ONLY).size > 0;
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+end;
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+class function TAndroidHelperEx.HasAssocApp(const URI: string): Boolean;
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+var
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+  Intent: JIntent;
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+begin
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+  Result := False;
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+  Intent := TJIntent.Create;
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+  Intent.setData(TJnet_Uri.JavaClass.parse(StringToJString(URI)));
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+  Intent.setAction(StringToJString('android.intent.action.VIEW'));
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+  Result := HasAssocApp(Intent);
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+end;
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 class function TAndroidHelperEx.IsActivityForeground: Boolean;
 
														 | 
														
														 | 
														
															 class function TAndroidHelperEx.IsActivityForeground: Boolean;
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 var
 
														 | 
														
														 | 
														
															 var
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   LService: JObject;
 
														 | 
														
														 | 
														
															   LService: JObject;
 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -170,7 +225,7 @@ var 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   I: Integer;
 
														 | 
														
														 | 
														
															   I: Integer;
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 begin
 
														 | 
														
														 | 
														
															 begin
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   Result := False;
 
														 | 
														
														 | 
														
															   Result := False;
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-  LService := TAndroidHelper.Context.getSystemService(TJContext.JavaClass.ACTIVITY_SERVICE);
 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+  LService := Context.getSystemService(TJContext.JavaClass.ACTIVITY_SERVICE);
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   LRunningApps := TJActivityManager.Wrap(TAndroidHelper.JObjectToID(LService)).getRunningAppProcesses;
 
														 | 
														
														 | 
														
															   LRunningApps := TJActivityManager.Wrap(TAndroidHelper.JObjectToID(LService)).getRunningAppProcesses;
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   for I := 0 to LRunningApps.size - 1 do
 
														 | 
														
														 | 
														
															   for I := 0 to LRunningApps.size - 1 do
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   begin
 
														 | 
														
														 | 
														
															   begin
 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -179,7 +234,7 @@ begin 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     begin
 
														 | 
														
														 | 
														
															     begin
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															       if LAppInfo.importanceReasonComponent <> nil then
 
														 | 
														
														 | 
														
															       if LAppInfo.importanceReasonComponent <> nil then
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															       begin
 
														 | 
														
														 | 
														
															       begin
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        if LAppInfo.importanceReasonComponent.getPackageName.equals(TAndroidHelper.Context.getPackageName) then
 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        if LAppInfo.importanceReasonComponent.getPackageName.equals(Context.getPackageName) then
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															           Exit(True);
 
														 | 
														
														 | 
														
															           Exit(True);
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															       end
 
														 | 
														
														 | 
														
															       end
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															       else if LRunningApps.size = 1 then
 
														 | 
														
														 | 
														
															       else if LRunningApps.size = 1 then
 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -188,14 +243,60 @@ begin 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   end;
 
														 | 
														
														 | 
														
															   end;
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 end;
 
														 | 
														
														 | 
														
															 end;
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
 
														 | 
														
														 | 
														
															 
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+class function TAndroidHelperEx.IsAppInstalled(const APackage: string): Boolean;
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+begin
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+  Result := False;
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+  try
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    //只有异常是可靠的,返回值判定不对
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    Result := Context.getPackageManager.getPackageInfo(StringToJString(S),
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+      TJPackageManager.JavaClass.GET_ACTIVITIES) = nil;
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    Result := True;
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+  except
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+  end;
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+end;
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+class function TAndroidHelperEx.KeepScreen(AOn: Boolean): Boolean;
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+begin
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+  CallInUIThreadAndWaitFinishing(
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    procedure
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    begin
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+      if AOn then
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        SharedActivity.getWindow.addFlags(
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+          TJWindowManager_LayoutParams.JavaClass.FLAG_KEEP_SCREEN_ON)
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+      else
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        SharedActivity.getWindow.clearFlags(
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+          TJWindowManager_LayoutParams.JavaClass.FLAG_KEEP_SCREEN_ON);
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    end);
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+end;
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+class procedure TAndroidHelperEx.SendAppToBack;
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+begin
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+  //SharedActivityManager.moveTaskToBack(Activity.getTaskId, TJIntent.JavaClass.FLAG_ACTIVITY_NEW_TASK);
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+  Activity.moveTaskToBack(True);
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+end;
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+class function TAndroidHelperEx.StartActivity(Intent: JIntent; const Code: Integer): Boolean;
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+begin
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+  Result := False;
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+  //Checks if there is at least one application capable of receiving the intent.
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+  if Activity.getPackageManager.queryIntentActivities(Intent,
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+      TJPackageManager.JavaClass.MATCH_DEFAULT_ONLY).size > 0 then begin
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    if Code = -1 then
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+      Activity.startActivity(Intent)
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    else
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+      Activity.startActivityForResult(Intent, Code);
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    Result := True;
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+  end;
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+end;
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 class function TAndroidHelperEx.UriFromFile(const AFile: JFile): Jnet_Uri;
 
														 | 
														
														 | 
														
															 class function TAndroidHelperEx.UriFromFile(const AFile: JFile): Jnet_Uri;
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 var
 
														 | 
														
														 | 
														
															 var
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   LAuthority: JString;
 
														 | 
														
														 | 
														
															   LAuthority: JString;
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 begin
 
														 | 
														
														 | 
														
															 begin
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   if CheckBuildAndTarget(NOUGAT) then
 
														 | 
														
														 | 
														
															   if CheckBuildAndTarget(NOUGAT) then
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   begin
 
														 | 
														
														 | 
														
															   begin
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    LAuthority := StringToJString(JStringToString(TAndroidHelper.Context.getApplicationContext.getPackageName) + '.fileprovider');
 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    Result := TJFileProvider.JavaClass.getUriForFile(TAndroidHelper.Context, LAuthority, AFile);
 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    LAuthority := StringToJString(JStringToString(Context.getApplicationContext.getPackageName) + '.fileprovider');
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    Result := TJFileProvider.JavaClass.getUriForFile(Context, LAuthority, AFile);
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   end
 
														 | 
														
														 | 
														
															   end
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   else
 
														 | 
														
														 | 
														
															   else
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     Result := TJnet_uri.JavaClass.fromFile(AFile);
 
														 | 
														
														 | 
														
															     Result := TJnet_uri.JavaClass.fromFile(AFile);
 
														 |