json link : http://www.payamakyab.com/sms/json/index/id/1
When I open this json link in the browser, it shows json code which is correct. But if i use this link to basic4android it does not shows the json code.
I use the following code in basic4android
#Region Project Attributes
#ApplicationLabel: json test new
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
Dim Parser As SaxParser
'Dim web As PhoneIntents
Dim hc As HttpClient
Dim req As HttpRequest
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim ps As LayoutValues
ps=GetDeviceLayoutValues
Dim tr As TextReader
Dim Title, Link, PubDate, Description As String
Dim m As Int=1
Dim d(20) As String
Dim i(20) As String
Dim psn As String
Dim aghaz , payan As Int
Dim a As Int
Dim b As Int
Dim c As Int
Dim e As Int
Dim gb As Int
Dim chek As Int
Dim lleft As Int
Dim psw As Int
Dim psh As Int
Dim lp As Int
Dim lsize As Int
Dim chek As Int
Dim t As Timer
Dim t1 As Timer
Dim t2 As Timer
Dim t3 As Timer
Dim t4 As Timer
Dim treader As Timer
Dim tchek As Timer
Dim lblpic(20) As Label
Dim lblname(20) As Label
Dim Label1 As Label
Dim Label2 As Label
Dim ListView1 As ListView
Dim Button1 As Button
Dim Button2 As Button
Dim Button3 As Button
Dim ListView1 As ListView
Dim WebView1 As WebView
Dim Button4 As Button
Dim Label3 As Label
Dim ImageView1 As ImageView
'Dim ap As ScrollView
Dim ScrollView1 As ScrollView
Dim EditText1 As EditText
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("l")
'ap.Initialize("")
'Activity.AddView(ap,0,0,100,100)
'WebView1.LoadUrl("http://www.payamakyab.com/sms/json/index/id/1")
'ap.Panel.LoadLayout("l")
Parser.Initialize
hc.Initialize("hc")
req.InitializeGet("http://www.payamakyab.com/sms/json/index/id/1")
hc.Execute(req, 1)
End Sub
'=#*==#*==#*==#*==#*==#*==#*==#*==#*==#*==#*==#*==#*==#*==#*==#*==#*==#*==#*==#*==#*==#*==#*==#*==#*==#*==#*==#*==#*==#*==#*==#*==#*=
'############################
'######## Fetch Data ########
'############################
Sub hc_ResponseSuccess(Response As HttpResponse, TaskId As Int)
Response.GetAsynchronously("GetRSS", File.OpenOutput(File.DirDefaultExternal, "RSS.xml", False), True, TaskId)
treader.Initialize("treader",1)
treader.Enabled=True
End Sub
Sub hc_ResponseError(Response As HttpResponse, Reason As String, StatusCode As Int, TaskId As Int)
If Response <> Null Then
Msgbox("Error: " & Response.GetString("UTF8"), "Connection Error")
Response.Release
End If
End Sub
Sub GetRSS_StreamFinish(Success As Boolean, TaskId As Int)
If Success = False Then
Msgbox(LastException.Message, "Error")
Return
End If
'Dim In As InputStream
'In = File.OpenInput(File.DirDefaultExternal, "RSS.xml")
'Parser.Parse(In, "Parser")
'In.Close
End Sub
'##########################
'######## Routines ########
'##########################
Sub Parser_StartElement(Uri As String, name As String, Attributes As Attributes)
End Sub
Sub Parser_EndElement(Uri As String, name As String, Text As StringBuilder)
If Parser.Parents.IndexOf("item") > -1 Then
If name = "title" Then
Title = Text.ToString
Else If name = "link" Then
Link = Text.ToString
Else If name = "pubdate" Then
PubDate = Text.ToString
Else If name = "description" Then
Description = Text.ToString
End If
End If
If name = "item" Then
hc.Execute(req, 1)
'RSS.TwoLinesLayout.Label.Gravity = Gravity.TOP
'RSS.TwoLinesLayout.Label.TextSize = 9dip
'RSS.TwoLinesLayout.Label.Height = 140dip
'RSS.TwoLinesLayout.ItemHeight = 140dip
'RSS.TwoLinesLayout.SecondLabel.TextSize = 8dip
'RSS.TwoLinesLayout.SecondLabel.Height = 140dip
'RSS.AddTwoLines2(Title, Description, Link)
End If
End Sub
Sub treader_tick
'If File.Exists(File.DirDefaultExternal, "RSS.xml") Then
Try
tr.Initialize(File.OpenInput(File.DirDefaultExternal, "RSS.xml"))
Label1.Text=tr.ReadList
'Msgbox(Label1.Text,"")
tr.Close
chek=Label1.Text.IndexOf("id")
If chek=-1 Then
Else
Msgbox(Label1.Text,"")
't.Initialize("t",1)
't.Enabled=True
treader.Enabled=False
End If
Catch
End Try
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
.
stackoverflow.comm
No comments:
Post a Comment