open pdf on Android via intents

I'm working in C++ on an FMX app on Android.  My app downloads a pdf file to the Downloads folder and now I want to let an external app display the pdf. 

I've managed to get it to open a pdf viewer (I installed Adobe on my Android) but it does not open the file.

I'm guessing i'm not passing the file path properly. Here is my code.

Androidapi::Jni::Graphicscontentviewtext::_di_JIntent intent = TJIntent::Create();
intent->setDataAndType(StringToJString("file://" + System::Ioutils::TPath::Combine(System::Ioutils::TPath::GetSharedDownloadsPath(), "sample.pdf")), StringToJString(L"application/pdf"));
if (SharedActivity()->getPackageManager()->queryIntentActivities(intent, TJPackageManager::JavaClass->MATCH_DEFAULT_ONLY)->size() > 0) {
} else {
  ShowMessage("PDF viewer not found");


russ (using Rio 10.3.2)

  • I GOT IT! Dave's help with this delphi question got me over the hump. Here is my code:
     _di_JIntent MyIntent;
     _di_Jnet_Uri Uri;
     UnicodeString URLtest;
     URLtest = System::Ioutils::TPath::Combine(System::Ioutils::TPath::GetSharedDownloadsPath(), "sample.pdf");
     Uri = TAndroidHelper::JFileToJURI(TJFile::JavaClass->init(StringToJString(URLtest)));
     MyIntent = TJIntent::JavaClass->init(TJIntent::JavaClass->ACTION_VIEW);
    Note, i had to make sure Secure File Sharing is true under Project->Options->Application->Entitlement List, and i had to make sure my app had access to the devices Storage. Very happy day....