Samsung issue? with OpenBrowser

cyclechris

Member
Licensed User
Longtime User
Hi All so I've got a problem. In an app I have:
StartActivity(pI.OpenBrowser(URL))

(pi = PhoneIntents, URL = string web page destination being passed in)
  • and that worked fine in the emulator and on an old HTC phone.
  • However on a new Samsung Note 2 I got ActivityNotFound Exception


So digging around a little found some ways to use Intent instead of Phone Intents:
pI.Initialize(pI.ACTION_VIEW,URL)
StartActivity(pI)

  • This got rid of the error but the Phone did not know what to use to carry out the ACTION_VIEW and didn't even list browser as an option

So then I tried SetComponent as follows:
pI.Initialize(pI.ACTION_VIEW,URL)
pI.SetComponent("com.android.browser/.BrowserActivity")
StartActivity(pI)

  • Same result as above, no page navigation


I also looked around some more and tried:
pI.Initialize(pI.ACTION_VIEW,URL)
pI.SetComponent("com.google.android.browser/com.android.browser.BrowserActivity")
StartActivity(pI)

  • But again I got ActivityNotFound Exception

Any ideas?
 

cyclechris

Member
Licensed User
Longtime User
Thanks Erel,

OK, here is where I generate the URL from user touching different areas of a splash screen:
B4X:
Sub Panel1_Touch(Action As Int, X As Float, Y As Float) As Boolean   
   showSplash
   szURLPanel.Initialize
   'MAKE URL BASED ON WHERE USER CLICKS OR TOUCHES
   If X>1 AND X<447 Then
      If Y>0 AND Y<118 Then
         szURLPanel.Remove(0,szURLPanel.Length)
         szURLPanel.Append("http://www.commdex.com")
         szShowURL = "Open Commdex? Or Channel Finder?"
      End If
   End If
   If Y >167 Then
      If X>46 AND X<404 Then
         If Y<373 Then
            If X<220 Then
               szURLPanel.Remove(0,szURLPanel.Length)
               szURLPanel.Append("http://www.commdex.com/federal")
               szShowURL = "Open Commdex-Federal? Or Channel Finder?"
            End If
            If X>227 Then
               szURLPanel.Remove(0,szURLPanel.Length)
               szURLPanel.Append("http://www.commdex.com/state-and-local")
               szShowURL = "Open Commdex-State&Local? Or Channel Finder?"
            End If
         End If
         If Y>374 AND Y<576 Then
            If X<220 Then
               szURLPanel.Remove(0,szURLPanel.Length)
               szURLPanel.Append("http://www.commdex.com/enterprise")
               szShowURL = "Open Commdex-Enterprise? Or Channel Finder?"
            End If
            If X>227 Then
               szURLPanel.Remove(0,szURLPanel.Length)
               szURLPanel.Append("http://www.commdex.com/its/index.php")
               szShowURL = "Open Commdex-IT? Or Channel Finder?"
            End If
         End If
      End If
   End If
   If Action = 1 Then ' SO WE ONLY FIRE ON CLICK NOT EVERY BUMP
      CallChoice(szShowURL,szURLPanel.ToString)
   End If   
   Return True
End Sub

This is working Properly, the URL's are coming out formed correctly

Then I call this code and give the user a choice to navigate to the web page or go on and open the app:
B4X:
Sub CallChoice(message As String, URL As String)
   Dim result As Int
   Dim pI As PhoneIntents 
   'Dim pI As Intent
   
   Dim theURL As String
   theURL = URL
   result = Msgbox2(szShowURL,"Web or Application?","Website","","Channel Finder",Null)
   Select result
       Case DialogResponse.POSITIVE
         Try
              StartActivity(pI.OpenBrowser(URL))
'              pI.Initialize(pI.ACTION_VIEW,theURL)
'              pI.SetComponent("com.android.browser/.BrowserActivity") 
'              pI.SetType("text/html")
'            StartActivity(pI)
            Catch
            ToastMessageShow("Error loading URL: " & LastException.message, True)
         End Try
       Case DialogResponse.CANCEL
           showSearch
       Case DialogResponse.NEGATIVE
           showSearch
   End Select
End Sub

You can see where I have commented out my experiments with Intent

PhoneIntents work great on my HTC Droid Incredible 2 Running Android 2.3.4

However, on my Samsung Galaxy Note 2 running Android 4.1.1, I get an ActivityNotFoundException
 
Upvote 0

cyclechris

Member
Licensed User
Longtime User
Thanks! Will do (dips) Good Idea on the Log, I was using a toaster message to test it when I was messing around with different things so I could see it on the phone itself, but I'll do that too.
 
Upvote 0

cyclechris

Member
Licensed User
Longtime User
Solved - Wow, I don't understand but am glad

OK, So I did 2 things that shouldn't really have made a difference. Instead of saving the passed in URL as another string I just commented that out and of course I put dip in the touch screen code.

Now It works just like I expected it to! Granted, it was sloppy coding (thanks for pointing that out!) But I'm just a little mystified as to why it made a difference.

But I'm glad it did!

So here's what I changed the code to:
B4X:
Sub Panel1_Touch(Action As Int, X As Float, Y As Float) As Boolean   
   showSplash
   szURLPanel.Initialize
   'MAKE URL BASED ON WHERE USER CLICKS OR TOUCHES
   If X>1dip AND X<447dip Then
      If Y>0dip AND Y<118dip Then
         szURLPanel.Remove(0,szURLPanel.Length)
         szURLPanel.Append("http://www.commdex.com")
         szShowURL = "Open Commdex? Or Channel Finder?"
      End If
   End If
   If Y >167dip Then
      If X>46dip AND X<404dip Then
         If Y<373dip Then
            If X<220dip Then
               szURLPanel.Remove(0,szURLPanel.Length)
               szURLPanel.Append("http://www.commdex.com/federal")
               szShowURL = "Open Commdex-Federal? Or Channel Finder?"
            End If
            If X>227dip Then
               szURLPanel.Remove(0,szURLPanel.Length)
               szURLPanel.Append("http://www.commdex.com/state-and-local")
               szShowURL = "Open Commdex-State&Local? Or Channel Finder?"
            End If
         End If
         If Y>374dip AND Y<576dip Then
            If X<220dip Then
               szURLPanel.Remove(0,szURLPanel.Length)
               szURLPanel.Append("http://www.commdex.com/enterprise")
               szShowURL = "Open Commdex-Enterprise? Or Channel Finder?"
            End If
            If X>227dip Then
               szURLPanel.Remove(0,szURLPanel.Length)
               szURLPanel.Append("http://www.commdex.com/its/index.php")
               szShowURL = "Open Commdex-IT? Or Channel Finder?"
            End If
         End If
      End If
   End If
   If Action = 1 Then ' SO WE ONLY FIRE ON CLICK NOT EVERY BUMP
      CallChoice(szShowURL,szURLPanel.ToString)
   End If   
   Return True
End Sub

Sub CallChoice(message As String, URL As String)
   Dim result As Int
   Dim pI As PhoneIntents 
   'Dim pI As Intent
   
   'Dim theURL As String
   'theURL = URL
   Log("URL is " & URL)
   result = Msgbox2(szShowURL,"Web or Application?","Website","","Channel Finder",Null)
   Select result
       Case DialogResponse.POSITIVE
         Try
              StartActivity(pI.OpenBrowser(URL))
'              pI.Initialize(pI.ACTION_VIEW,theURL)
'              pI.SetComponent("com.android.browser/.BrowserActivity") 
'              pI.SetType("text/html")
'            StartActivity(pI)
            Catch
            ToastMessageShow("Error loading URL: " & URL & " - " & LastException.message, True)
         End Try
       Case DialogResponse.CANCEL
           showSearch
       Case DialogResponse.NEGATIVE
           showSearch
   End Select
End Sub
 
Upvote 0
Top