phoneintents error

Cor

Active Member
Licensed User
Longtime User
gives error

no activity found to handle Intent

using android 8 sdk
phone lib 1.31

B4X:
dim p as phoneintents
dim url as string

    url="maps.google.nl/maps?f=d&source=s_d&saddr=parklaan+20+oss&daddr=hunnenpad+6+oss&hl=nl"
    StartActivity(p.OpenBrowser(url))
 

csgoh

Member
Licensed User
Longtime User
How could I open a local html file in SD card?

I tried this, but got 'no activity found to handle Intent' error

B4X:
Dim p As PhoneIntents
StartActivity(p.OpenBrowser("file:///mnt/sdcard/dmDoc.html"))
Any other suggestions?
 
Upvote 0

Dman

Active Member
Licensed User
Longtime User
I added this code and got this error.

B4X:
    Dim i As Intent
i.Initialize(i.ACTION_VIEW, "file://" & File.Combine(File.DirInternal, "invoice.html"))'
i.SetComponent("com.android.browser/.BrowserActivity")
StartActivity(i)

and got this error.

An error has occured in sub:
invoice_btnemail_click (java line:414)
android.content.ActivityNotFoundException:
Unable to find explicit activity class {com.
android.browser/com.android.browser.
BrowserActivity}; have you declared this activity
in your AndroidManifest.xml?
Continue?


Any ideas?
 
Upvote 0

mistermentality

Active Member
Licensed User
Longtime User
I'm having the exact same error message using the amended code on a stock Nexus 7 running Android 4.2 trying to open a local web page from my apps internal directory (not assets folder) in web browser.

I was wondering has anyone found a way around this that works on 4.2?

Dave
 
Upvote 0

mistermentality

Active Member
Licensed User
Longtime User
You will need to explicitly set the default browser as the target:
B4X:
   Dim i As Intent
   i.Initialize(i.ACTION_VIEW, "file://" & File.Combine(File.DirRootExternal, "1.html"))
   i.SetComponent("com.android.browser/.BrowserActivity")
   StartActivity(i)

I was referring to this post, sorry.

For some reason it will not work, compiles fine but whenever I call it the app errors out.

Dave

Sent from my Nexus 7
 
Upvote 0

mistermentality

Active Member
Licensed User
Longtime User
You can use this code to find the correct component:
B4X:
Sub GetBrowserComponent As String
   Dim pm As PackageManager
   Dim i As Intent
   i.Initialize(i.ACTION_VIEW, "http://")
   Return pm.QueryIntentActivities(i).Get(0)
End Sub

Thanks but it returns Chrome as the component, which is great but if I force Chrome to open the page won't the app still fail when on devices without Chrome installed, does this mean there is no way to open a local web page in the default browser that will work across devices?

Thanks,

Dave
 
Upvote 0

mistermentality

Active Member
Licensed User
Longtime User
You should use this method to find the component. You do not need to "hardcode" it. It will work on all devices.

Forgive me sounding a bit dumb here but it says the component us chrome and I thought if chrome is not on a device then it can't call it so would fail?

I have used a Webview now but will try it again on different device when can get one. Thanks

Dave

Sent from my Nexus 7
 
Upvote 0
Top