Android Question OpenBrowser - Samsung

MarcoRome

Expert
Licensed User
Longtime User
Hi Erel, all
When i try this code on Samsung S7


B4X:
Sub ListView1_ItemClick (Position As Int, Value As Object)
    Dim pi As PhoneIntents
    Log("Value: " & Value) '= http://www.gazzetta.it/Calcio/Serie-A/Inter/04-01-2017/joao-mario-punta-champions-ancora-possibile-credo-nell-inter-gabigol-suning-180280421151.shtml
     StartActivity(pi.OpenBrowser(Value))
End Sub

i have this error:

android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=
http://www.gazzetta.it/Calcio/Serie...-nell-inter-gabigol-suning-180280421151.shtml
flg=0x20000 VirtualScreenParam=Params{mDisplayId=-1, null, mFlags=0x00000000)} }
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1878)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1545)
at android.app.Activity.startActivityForResult(Activity.java:4283)
at android.app.Activity.startActivityForResult(Activity.java:4230)
at android.app.Activity.startActivity(Activity.java:4567)
at android.app.Activity.startActivity(Activity.java:4535)
at anywheresoftware.b4a.keywords.Common.StartActivity(Common.java:698)
at b4a.example.main._listview1_itemclick(main.java:512)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
at anywheresoftware.b4a.BA$1.run(BA.java:293)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7229)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)

If i run this code is OK.
B4X:
  StartActivity(pi.OpenBrowser("http://www.gazzetta.it/Calcio/Serie-A/Juventus/04-01-2017/rugani-carica-feroce-supercoppa-180280496426.shtml"))

:confused:
Any idea ?
 

DonManfred

Expert
Licensed User
Longtime User
Cast the Object to a string first


Try
B4X:
Sub ListView1_ItemClick (Position As Int, Value As Object)
    dim url as string = value
    Dim pi As PhoneIntents
    Log("Value: " & url) '= http://www.gazzetta.it/Calcio/Serie-A/Inter/04-01-2017/joao-mario-punta-champions-ancora-possibile-credo-nell-inter-gabigol-suning-180280421151.shtml
     StartActivity(pi.OpenBrowser(url))
End Sub
 
Upvote 0

MarcoRome

Expert
Licensed User
Longtime User
Cast the Object to a string first


Try
B4X:
Sub ListView1_ItemClick (Position As Int, Value As Object)
    dim url as string = value
    Dim pi As PhoneIntents
    Log("Value: " & url) '= http://www.gazzetta.it/Calcio/Serie-A/Inter/04-01-2017/joao-mario-punta-champions-ancora-possibile-credo-nell-inter-gabigol-suning-180280421151.shtml
     StartActivity(pi.OpenBrowser(url))
End Sub
Already tried.... dont work
 
Upvote 0

MarcoRome

Expert
Licensed User
Longtime User
The value of Value is not what you expect. Maybe there are extra spaces.

What is the output of:
B4X:
Log(Value)
Log(Value.Length)
Copy from the logs with right click.

Hi Erel, thank you for your answer.

upload_2017-1-5_9-39-59.png


This is Value from Log Windows ( Log("Value: " & Value)


This is all log:
** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
{"rss":{"Attributes":{"version":"2.0"},"channel":{"title":"Gazzetta.it","link":"http:\/\/www.gazzetta.it\/","description":"Gazzetta dello Sport online","copyright":"Copyright 2004 - RCS MediaGroup","language":"it-IT","lastBuildDate":"Wed, 4 Jan 2017 20:20:46 +0100","generator":"Eidosmedia Méthode","image":{"title":"Gazzetta.it","url":"http:\/\/www.gazzetta.it\/rss\/images\/logo_small.gif","link":"http:\/\/www.gazzetta.it\/","width":"140","height":"40","description":"Gazzetta.it versione rss"},"item":[{"position":"1 - 8","title":"\n\nJoao Mario suona la carica \"La Champions è possibile E Gabigol giocherà di più...\"\n\n","description":"\n\nJoao Mario suona la carica \"La Champions è possibile E Gabigol giocherà di più...\"<br\/> <b>Il portoghese ha risposto ai tifosi dall’account Facebook del club: “Suning ci ha messo nelle condizioni di tornare in alto. Gabigol giocherà sempre di più”<\/b> <br\/>\n\n","link":"\nhttp:\/\/www.gazzetta.it\/Calcio\/Serie-A\/Inter\/04-01-2017\/joao-mario-punta-champions-ancora-possibile-credo-nell-inter-gabigol-suning-180280421151.shtml\n","creator":"\n Gasport \n","guid":{"Attributes":{"isPermaLink":"true"},"Text":"\nhttp:\/\/www.gazzetta.it\/Calcio\/Serie-A\/Inter\/04-01-2017\/joao-mario-punta-champions-ancora-possibile-credo-nell-inter-gabigol-suning-180280421151.shtml\n"},"category":{"Attributes":{"domain":"http:\/\/www.gazzetta.it"},"Text":"Calcio"},"pubDate":"Wed, 4 Jan 2017 17:19:55 +0100","enclosure":[{"Attributes":{"url":"http:\/\/images2.gazzettaobjects.it\/methode_image\/2017\/01\/04\/Calcio\/Foto%20Calcio%20-%20Trattate\/ce1288447fb1d5138cab32aa0168795b_169_xl.jpg"},"Text":""},{"Attributes":{"url":"http:\/\/images2.gazzettaobjects.it\/methode_image\/2017\/01\/04\/Calcio\/Foto%20Calcio%20-%20Trattate\/ce1288447fb1d5138cab32aa0168795b_43_l.jpg"},"Text":""}]},{"position":"2 - 8","title":"\n\nRugani: \"Doha ci fa male Abbiamo una carica feroce\"\n\n","description":"\n\nRugani: \"Doha ci fa male Abbiamo una carica feroce\" <br\/> <b>\"Alle sconfitte abbiamo sempre reagito con forza\", ha detto il difensore. \"Col Bologna sarà dura è la squadra che l'anno scorso campionato ha interrotto la nostra serie di vittorie\"<\/b> <br\/>\n\n","link":"\nhttp:\/\/www.gazzetta.it\/Calcio\/Serie-A\/Juventus\/04-01-2017\/rugani-carica-feroce-supercoppa-180280496426.shtml\n","creator":"\n Gasport \n","guid":{"Attributes":{"isPermaLink":"true"},"Text":"\nhttp:\/\/www.gazzetta.it\/Calcio\/Serie-A\/Juventus\/04-01-2017\/rugani-carica-feroce-supercoppa-180280496426.shtml\n"},"category":{"Attributes":{"domain":"http:\/\/www.gazzetta.it"},"Text":"Calcio"},"pubDate":"Wed, 4 Jan 2017 17:12:22 +0100","enclosure":[{"Attributes":{"url":"http:\/\/images2.gazzettaobjects.it\/methode_image\/2017\/01\/04\/Calcio\/Foto%20Calcio%20-%20Trattate\/57f6b28b390513f0ffee7e839cdd2cee_169_xl.jpg"},"Text":""},{"Attributes":{"url":"http:\/\/images2.gazzettaobjects.it\/methode_image\/2017\/01\/04\/Calcio\/Foto%20Calcio%20-%20Trattate\/57f6b28b390513f0ffee7e839cdd2cee_43_l.jpg"},"Text":""}]}]}}}
Title:
Joao Mario suona la carica "La Champions è possibile E Gabigol giocherà di più..."
Link:
http://www.gazzetta.it/Calcio/Serie...-nell-inter-gabigol-suning-180280421151.shtml
Title:
Rugani: "Doha ci fa male Abbiamo una carica feroce"
Link:
http://www.gazzetta.it/Calcio/Serie...i-carica-feroce-supercoppa-180280496426.shtml
** Activity (main) Resume **
Value:
http://www.gazzetta.it/Calcio/Serie...-nell-inter-gabigol-suning-180280421151.shtml
main_listview1_itemclick (B4A line: 52)
StartActivity(pi.OpenBrowser(Value))
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=
http://www.gazzetta.it/Calcio/Serie...-nell-inter-gabigol-suning-180280421151.shtml
flg=0x20000 VirtualScreenParam=Params{mDisplayId=-1, null, mFlags=0x00000000)} }
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1878)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1545)
at android.app.Activity.startActivityForResult(Activity.java:4283)
at android.app.Activity.startActivityForResult(Activity.java:4230)
at android.app.Activity.startActivity(Activity.java:4567)
at android.app.Activity.startActivity(Activity.java:4535)
at anywheresoftware.b4a.keywords.Common.StartActivity(Common.java:698)
at b4a.example.main._listview1_itemclick(main.java:508)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
at anywheresoftware.b4a.BA$1.run(BA.java:293)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7229)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)

In attachment also example
 

Attachments

  • rss-example.zip
    8.8 KB · Views: 261
Upvote 0

MarcoRome

Expert
Licensed User
Longtime User
Mhhh...
I thought that exporting via:

upload_2017-1-5_10-20-14.png


would save the whole project.
Anyway this is a zipped "manual" copy
 

Attachments

  • Rss.zip
    13.3 KB · Views: 252
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0

MarcoRome

Expert
Licensed User
Longtime User
B4X:
Log("Value: " & Value)

Output:
Value:
http://www.gazzetta.it/Calcio/Serie...-nell-inter-gabigol-suning-180280421151.shtml

This can only mean one thing. 'Value' starts with a new line character.

Solution 1:
B4X:
ListView1.AddSingleLine2(title, link.Trim)
Solution 2:
B4X:
Dim link As String = Value
StartActivity(pi.OpenBrowser(link.Trim))
Of course you are right.

In xml code i read this:
B4X:
.....
<title>
<![CDATA[
Joao Mario suona la carica "La Champions è possibile E Gabigol giocherà di più..."
]]>
</title>
.....
<link>
http://www.gazzetta.it/Calcio/Serie-A/Inter/04-01-2017/joao-mario-punta-champions-ancora-possibile-credo-nell-inter-gabigol-suning-180280421151.shtml
</link>
.....
and i dont see new line here.
The same thing happen with all fields ( title, link, etc ).

I tried also about another xml file ( another site http://www.ansa.it/sito/ansait_rss.xml )
I have the same problem.
So i correct the Class in this point:

upload_2017-1-5_13-33-7.png



Thank you for this Class @Erel is very useful class
 
Last edited:
Upvote 0
Top