Blank Screen

bishmedia

Member
Licensed User
Longtime User
I have a simple App that shows several websites and the orientation is set permanently to Landscape.
Everything works fine apart from when you turn the phone/tablet off and turn it on at a later date the App is blank??

Can anyone help, code is below...

B4X:
#Region Module Attributes
   #FullScreen: False
   #IncludeTitle: True
   #VersionCode: 1
   #VersionName: 
   #SupportedOrientations: landscape
   #CanInstallToExternalStorage: True
#End Region

#Region Module Attributes
   #FullScreen: True
   #IncludeTitle: False
   #ApplicationLabel: Brapp
   #VersionCode: 2
   #VersionName:  
   #SupportedOrientations: landscape
   #CanInstallToExternalStorage: False
#End Region

Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'These variables can be accessed from all modules.
Dim page As String
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 WebView1 As WebView
   Dim btnDown1 As Button
   Dim btnDown2 As Button
   Dim btnDown3 As Button
   Dim pnlLower As Panel
   Dim btnDatabase As Button
   Dim ImageView1 As ImageView
   Dim btnBack As Button
   Dim btnForward As Button
   Dim btnMain As Button
End Sub

Sub Activity_Create(FirstTime As Boolean)
  If FirstTime Then
    WebView1.Initialize("brass_band_Click")
    Activity.LoadLayout("brass_band")

    WebView1.LoadURL("http://www.bishmedia.co.uk/default/Apps/index.php")
  End If
End Sub
Sub btnDown1_Click
   WebView1.LoadURL("http://www.4barsrest.com")
   UpdateView
   CloseMainButtons
End Sub
Sub btnDown2_Click
   WebView1.LoadURL("http://www.britishbandsman.com")
   UpdateView
   CloseMainButtons   
End Sub
Sub btnDown3_Click
   WebView1.LoadURL("http://www.themouthpiece.com")
   UpdateView
   CloseMainButtons   
End Sub
Sub btnDatabase_Click
   WebView1.LoadURL("http://www.bishmedia.co.uk/default/Apps/selectbycompetition.php")
   UpdateView   
End Sub
Sub btnMain_click
   ShowMainButtons
End Sub
Sub UpdateView
   Dim WebViewSettings1 As WebViewSettings
    WebViewSettings1.setDefaultZoom(WebView1, "FAR")
    WebViewSettings1.setLoadWithOverviewMode(WebView1, True)    
    WebViewSettings1.setUseWideViewPort(WebView1, True)
End Sub
Sub CloseMainButtons
   btnDown1.Visible = False
   btnDown2.Visible = False
   btnDown3.Visible = False
   btnDatabase.Visible = False
   btnBack.Visible = True
   btnForward.Visible = True
   btnMain.Visible   = True
End Sub
Sub ShowMainButtons
   btnDown1.Visible = True
   btnDown2.Visible = True
   btnDown3.Visible = True
   btnDatabase.Visible = True
   btnBack.Visible = False
   btnForward.Visible = False
   btnMain.Visible = False
End Sub
 

NJDude

Expert
Licensed User
Longtime User
That's because you have this:
B4X:
  If FirstTime Then
    WebView1.Initialize("brass_band_Click")
    Activity.LoadLayout("brass_band")

    WebView1.LoadURL("http://www.bishmedia.co.uk/default/Apps/index.php")
  End If
take those lines out of FirstTime, that means, those lines will only execute THE VERY FIRST TIME you run the app.
 
Upvote 0

bishmedia

Member
Licensed User
Longtime User
I had an issue in the past that when i switched the phone off and back on it didn't go back to the last site i used and i was advised to add the 'If Firsttime Then' parameters???

Catch 22, i guess if a person switches of the phone they've finished with the app :)
 
Upvote 0

bishmedia

Member
Licensed User
Longtime User
Done it, thanks for the pointer :)

B4X:
Sub Process_Globals
      Dim web As String
End Sub

Sub Activity_Create(FirstTime As Boolean)
   If FirstTime Then
       WebView1.Initialize("brass_band_Click")
       Activity.LoadLayout("brass_band")
       WebView1.LoadURL("http://www.bishmedia.co.uk/default/Apps/index.php")
   Else
       WebView1.Initialize("brass_band_Click")
       Activity.LoadLayout("brass_band")   
      WebView1.LoadUrl(web)
   End If
End Sub
Sub Activity_Pause (UserClosed As Boolean)
   web = WebView1.Url   
End Sub
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
SInce you HAVE to run these 2 lines of code;
B4X:
WebView1.Initialize("brass_band_Click")
Activity.LoadLayout("brass_band")
You can change the Activity_Create to this

B4X:
Sub Activity_Create(FirstTime As Boolean)
   WebView1.Initialize("brass_band_Click")
   Activity.LoadLayout("brass_band")
   If FirstTime Then
       WebView1.LoadURL("http://www.bishmedia.co.uk/default/Apps/index.php")
   Else
      WebView1.LoadUrl(web)
   End If
End Sub
 
Upvote 0
Top