Home Google Apps does not receive an Intent from the Firemonkey app
Reply: 0

Google Apps does not receive an Intent from the Firemonkey app

Vincent J
1#
Vincent J Published in 2017-11-15 00:36:27Z

I want to implement something like ShellExcute() but on Android.

I want to use an Intent to open a file in an external app.

I think it works well when tested, but for xlsx, ppt, and pdf extensions, my default Google apps (Spreadsheets, Presentations, Drive PDF viewers) are not receiving the file.

There is no problem with images and galleries in Google apps.

So, if I get the MIME-Type and there is no app for it, my code throws an exception:

I can handle exceptions, but Google apps are not being displayed in the selection list, even if I set the MIME-Type to */*.

That's why I have a basic Google apps, which forces users to install third-party apps.

What do I have to do for Google apps to get my Intent?

When I open the corresponding file using ES File Explorer on my device, those Google apps come out well.

This problem occurs equally well when testing both my device and the emulator.

Below is the example code I tested:

uses
  Androidapi.JNI.GraphicsContentViewText,
  Androidapi.JNI.JavaTypes,
  Androidapi.Helpers,
  System.IOUtils,
  Androidapi.JNI.Webkit;

{$R *.fmx}

procedure TForm1.Button1Click(Sender: TObject);
var
  Intent: JIntent;
  filename: String;
  t: JString;
begin
  filename := Edit1.text;
  Intent := TJIntent.Create;

  // Get MIME Type
  t := TJMimeTypeMap.JavaClass.getSingleton.getMimeTypeFromExtension
        (StringToJString (StringReplace (TPath.GetExtension(filename), '.', '', [])));
  if t = nil then
    t := StringToJString('*/*');

  Intent.setAction(TJIntent.JavaClass.ACTION_VIEW);
  Intent.setDataAndType(StrToJURI(TPath.GetPublicPath + PathDelim + filename),  t);
  SharedActivity.startActivity(Intent);
end;
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.32641 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO