Open browser without using phone library

niqpw

Member
Licensed User
Longtime User
Would this be possible? Maybe using the reflection library?

It would be useful as the only requirement I have for the phone library in my app is to open the browser, which works fine but adds the "READ PHONE STATE AND IDENTITY" permissions which can be off-putting for users.

Here's my code:

B4X:
Sub Webview1_OverrideUrl (Url As String) As Boolean
   Dim p As PhoneIntents
   Dim intResponse As Int
   
   intResponse =    Msgbox2("View item?", "View item","Go to Site","Maybe later!","",Null)
   If intResponse = DialogResponse.POSITIVE Then
       StartActivity(p.OpenBrowser(Url))
   End If
   Return    True
End Sub

Thanks in advance for any help!
 

niqpw

Member
Licensed User
Longtime User
Thanks Erel, I was making an assumption that that was the culprit. This was the code to blame:

B4X:
   Dim ph As Phone
   Dim bd As BitmapDrawable
   bd = ph.GetResourceDrawable(17301571)
   Activity.AddMenuItem2("Select your region", "mnuHelp", bd.Bitmap )

So I might just bundle that image with the app, rather than getting it through this method. Is that the best way?
 
Upvote 0

niqpw

Member
Licensed User
Longtime User
For info, this works for me:

B4X:
   Dim objIcon As Bitmap
   Dim strFilename As String
   strFilename = "ic_menu_mapmode.png"
   Dim objIn As InputStream
   If    File.Exists(File.DirAssets,strFilename) = True Then
      objIn = File.OpenInput(File.DirAssets, strFilename)
      objIcon.Initialize2(objIn)
      Activity.AddMenuItem2("Select your region", "mnuHelp", objIcon )
   End If

Where ic_menu_mapmode.png has already been added to your project. These resources are good:

Resource.Drawable Members

Androidâ„¢ 1.5 android.R.drawable Icon Resources
 
Last edited:
Upvote 0
Top