Android Question PDF Intent URI problem

yiankos1

Well-Known Member
Licensed User
Longtime User
I use this code to read a pdf:
B4X:
Private dir As String
    dir=pr.GetSafeDirDefaultExternal("shared")
   
    Try
        Dim Intent1 As Intent
       
        Intent1.Initialize(Intent1.ACTION_VIEW,"")
        Intent1.SetType("application/pdf")
        Intent1.PutExtra("android.intent.extra.STREAM",  CreateFileProviderUri(dir, "book.pdf"))
        Intent1.Flags = 1

        StartActivity(Intent1)
    Catch
        ToastMessageShow("Error",True)
    End Try

Manifest:
B4X:
AddApplicationText(
  <provider
  android:name="android.support.v4.content.FileProvider"
  android:authorities="$PACKAGE$.provider"
  android:exported="false"
  android:grantUriPermissions="true">
  <meta-data
  android:name="android.support.FILE_PROVIDER_PATHS"
  android:resource="@xml/provider_paths"/>
  </provider>
)
CreateResource(xml, provider_paths,
   <external-files-path name="name" path="shared" />

I get this error:
B4X:
Error occurred on line: 725 (Main)
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW typ=application/pdf flg=0x20001 (has extras) }
    at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1937)
    at android.app.Instrumentation.execStartActivity(Instrumentation.java:1616)
    at android.app.Activity.startActivityForResult(Activity.java:4487)
    at android.support.v4.app.BaseFragmentActivityApi16.startActivityForResult(BaseFragmentActivityApi16.java:54)
    at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:68)
    at android.app.Activity.startActivityForResult(Activity.java:4445)
    at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:751)
    at android.app.Activity.startActivity(Activity.java:4806)
    at android.app.Activity.startActivity(Activity.java:4774)
    at anywheresoftware.b4a.keywords.Common.StartActivity(Common.java:848)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:780)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:363)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:260)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:175)
    at de.donmanfred.IconButtonWrapper$1.onClick(IconButtonWrapper.java:72)
    at android.view.View.performClick(View.java:6294)
    at android.view.View$PerformClick.run(View.java:24770)
    at android.os.Handler.handleCallback(Handler.java:790)
 

DonManfred

Expert
Licensed User
Longtime User
Upvote 0
Top