|
@@ -75,20 +75,29 @@ type
|
|
|
/// Useful from within a service to determine whether or not the service needs to run in foreground mode
|
|
|
/// </remarks>
|
|
|
class function IsActivityForeground: Boolean; static;
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// Converts file to uri, without FileProvider
|
|
|
+ /// </summary>
|
|
|
+ class function UriFromFile(const AFile: JFile): Jnet_Uri; overload; static;
|
|
|
+ /// <summary>
|
|
|
+ /// Converts file to uri, without FileProvider
|
|
|
+ /// </summary>
|
|
|
+ class function UriFromFile(const AFileName: string): Jnet_Uri; overload; static;
|
|
|
/// <summary>
|
|
|
/// Converts file to uri, using FileProvider if target API >= 24
|
|
|
/// </summary>
|
|
|
/// <remarks>
|
|
|
/// Use this only when accessing files with an "external" URI
|
|
|
/// </remarks>
|
|
|
- class function UriFromFile(const AFile: JFile; const AAuthority: string = ''): Jnet_Uri; overload; static;
|
|
|
+ class function SharedUriFromFile(const AFile: JFile; const AAuthority: string = ''): Jnet_Uri; overload; static;
|
|
|
/// <summary>
|
|
|
/// Converts filename to uri, using FileProvider if target API >= 24
|
|
|
/// </summary>
|
|
|
/// <remarks>
|
|
|
/// Use this only when accessing files with an "external" URI
|
|
|
/// </remarks>
|
|
|
- class function UriFromFile(const AFileName: string; const AAuthority: string = ''): Jnet_Uri; overload; static;
|
|
|
+ class function SharedUriFromFile(const AFileName: string; const AAuthority: string = ''): Jnet_Uri; overload; static;
|
|
|
|
|
|
/// <summary>Returns Java Application Context</summary>
|
|
|
class property Context: JContext read GetJContext;
|
|
@@ -263,7 +272,7 @@ begin
|
|
|
LIntent.setAction(TJIntent.JavaClass.ACTION_VIEW);
|
|
|
// 没有这个也可以安装成功,但是安装成功后的成功页面,也就是,完成/打开 会无法显示
|
|
|
LIntent.addFlags(TJIntent.JavaClass.FLAG_ACTIVITY_NEW_TASK);
|
|
|
- LIntent.setDataAndType(UriFromFile(AFileName, AAuthority),
|
|
|
+ LIntent.setDataAndType(SharedUriFromFile(AFileName, AAuthority),
|
|
|
StringToJString('application/vnd.android.package-archive'));
|
|
|
LIntent.addFlags(TJIntent.JavaClass.FLAG_GRANT_READ_URI_PERMISSION);
|
|
|
Result := StartActivity(LIntent);
|
|
@@ -335,7 +344,17 @@ begin
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
-class function TAndroidHelperEx.UriFromFile(const AFile: JFile; const AAuthority: string): Jnet_Uri;
|
|
|
+class function TAndroidHelperEx.UriFromFile(const AFileName: string): Jnet_Uri;
|
|
|
+begin
|
|
|
+ Result := UriFromFile(TJFile.JavaClass.init(StringToJString(AFileName)));
|
|
|
+end;
|
|
|
+
|
|
|
+class function TAndroidHelperEx.UriFromFile(const AFile: JFile): Jnet_Uri;
|
|
|
+begin
|
|
|
+ Result := TJnet_uri.JavaClass.fromFile(AFile);
|
|
|
+end;
|
|
|
+
|
|
|
+class function TAndroidHelperEx.SharedUriFromFile(const AFile: JFile; const AAuthority: string): Jnet_Uri;
|
|
|
var
|
|
|
LAuthority: JString;
|
|
|
begin
|
|
@@ -350,9 +369,9 @@ begin
|
|
|
Result := TJnet_uri.JavaClass.fromFile(AFile);
|
|
|
end;
|
|
|
|
|
|
-class function TAndroidHelperEx.UriFromFile(const AFileName, AAuthority: string): Jnet_Uri;
|
|
|
+class function TAndroidHelperEx.SharedUriFromFile(const AFileName, AAuthority: string): Jnet_Uri;
|
|
|
begin
|
|
|
- Result := UriFromFile(TJFile.JavaClass.init(StringToJString(AFileName)), AAuthority);
|
|
|
+ Result := SharedUriFromFile(TJFile.JavaClass.init(StringToJString(AFileName)), AAuthority);
|
|
|
end;
|
|
|
|
|
|
end.
|