Android Question Localstorage

Mynak

New Member
#Region Project Attributes
#ApplicationLabel: Ningen
#VersionCode: 3
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: portrait
#CanInstallToExternalStorage: False
#End Region

#Region Activity Attributes
#FullScreen: False
#IncludeTitle: False
#End Region

Sub Process_Globals
Private PreviousPages As List
Private xui As XUI
End Sub

Sub Globals
Private WebView1 As WebView
End Sub

Sub Activity_Create(FirstTime As Boolean)
PreviousPages.Initialize ' PreviousPages listesini başlat
Activity.LoadLayout("wv")
Dim webViewExtras As WebViewExtras
webViewExtras.Initialize(WebView1)
WebView1.LoadUrl("https://website.com")
End Sub


Sub Activity_KeyPress (KeyCode As Int) As Boolean
If KeyCode = KeyCodes.KEYCODE_BACK Then ' Kullanıcı geri düğmesine bastığında
If PreviousPages.Size > 1 Then ' En az bir önceki sayfa varsa
' Şu anki sayfayı listeden kaldır
PreviousPages.RemoveAt(PreviousPages.Size - 1)
' Önceki sayfaya geri dön
WebView1.LoadUrl(PreviousPages.Get(PreviousPages.Size - 1))
Return True ' Geri tuşunun varsayılan işlevini engelle
End If
End If
Return False ' Diğer tuş vuruşlarını işlemek için varsayılan geri dönüş değeri
End Sub

Sub WebView1_PageFinished (Url As String)
If PreviousPages.Size = 0 Or PreviousPages.Get(PreviousPages.Size - 1) <> Url Then
' Eğer listede hiç URL yoksa veya son eklenen URL şu anki URL'den farklı ise
PreviousPages.Add(Url) ' URL'yi önceki sayfalar listesine ekle
End If
End Sub


so when I remove about localstorage commands on my website page is working but if page have local storage commands page not working
 

Mynak

New Member
1. Please use [code]code here...[/code] tags when posting code.

2. Switch to B4XPages.

3. Use WebViewSettings library and enable domstorage: https://www.b4x.com/android/forum/threads/webview-vs-local-storage-solved.157506/#post-966861
how to switch B4XPages? sorry it's my first time to use b4a.


B4X:
#Region  Project Attributes
    #ApplicationLabel: Ningen
    #VersionCode: 3
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: portrait
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: False
#End Region

Sub Process_Globals
    Private PreviousPages As List
    Private xui As XUI
End Sub

Sub Globals
    Private WebView1 As WebView
End Sub

Sub Activity_Create(FirstTime As Boolean)
    PreviousPages.Initialize ' PreviousPages listesini başlat
    Activity.LoadLayout("wv")
    Dim webViewExtras As WebViewExtras
    webViewExtras.Initialize(WebView1)
    WebView1.LoadUrl("https://website.com")
End Sub


Sub Activity_KeyPress (KeyCode As Int) As Boolean
    If KeyCode = KeyCodes.KEYCODE_BACK Then ' Kullanıcı geri düğmesine bastığında
        If PreviousPages.Size > 1 Then ' En az bir önceki sayfa varsa
            ' Şu anki sayfayı listeden kaldır
            PreviousPages.RemoveAt(PreviousPages.Size - 1)
            ' Önceki sayfaya geri dön
            WebView1.LoadUrl(PreviousPages.Get(PreviousPages.Size - 1))
            Return True ' Geri tuşunun varsayılan işlevini engelle
        End If
    End If
    Return False ' Diğer tuş vuruşlarını işlemek için varsayılan geri dönüş değeri
End Sub

Sub WebView1_PageFinished (Url As String)
    If PreviousPages.Size = 0 Or PreviousPages.Get(PreviousPages.Size - 1) <> Url Then
        ' Eğer listede hiç URL yoksa veya son eklenen URL şu anki URL'den farklı ise
        PreviousPages.Add(Url) ' URL'yi önceki sayfalar listesine ekle
    End If
End Sub
 
Upvote 0

Shelby

Well-Known Member
Licensed User
SQLite App:
#Region  Project Attributes
    #ApplicationLabel: The Shelby Code
    #VersionCode: 1
    #VersionName: 1
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: portrait
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes
    #FullScreen: True
    #IncludeTitle: False
#End Region

#BridgeLogger: True

Sub Process_Globals
    Public ActionBarHomeClicked As Boolean
End Sub

Sub Globals

End Sub

Sub Activity_Create(FirstTime As Boolean)
    Dim pm As B4XPagesManager
    pm.Initialize(Activity)
   
End Sub

'Template version: B4A-1.01
#Region Delegates

Sub Activity_ActionBarHomeClick
    ActionBarHomeClicked = True
    B4XPages.Delegate.Activity_ActionBarHomeClick
    ActionBarHomeClicked = False
End Sub

Sub Activity_KeyPress (KeyCode As Int) As Boolean
    Return B4XPages.Delegate.Activity_KeyPress(KeyCode)
End Sub

Sub Activity_Resume
    B4XPages.Delegate.Activity_Resume
End Sub

Sub Activity_Pause (UserClosed As Boolean)
    B4XPages.Delegate.Activity_Pause
End Sub

Sub Activity_PermissionResult (Permission As String, Result As Boolean)
    B4XPages.Delegate.Activity_PermissionResult(Permission, Result)
End Sub

Sub Create_Menu (Menu As Object)
    B4XPages.Delegate.Create_Menu(Menu)
End Sub

#if Java
public boolean _onCreateOptionsMenu(android.view.Menu menu) {
     processBA.raiseEvent(null, "create_menu", menu);
     return true;

This is just to give you an idea of how B4XPages can be used. This is the main page code for an SQLite app.
 
Upvote 0

asales

Expert
Licensed User
Longtime User
how to switch B4XPages? sorry it's my first time to use b4a.
You need to create a new project using B4XPages format and put your code.

As is your first time to use B4A, is better to start in the right way.

There are several tutorials in the forum with information about B4XPages:
 
Upvote 0

Mynak

New Member
You need to create a new project using B4XPages format and put your code.

As is your first time to use B4A, is better to start in the right way.

There are several tutorials in the forum with information about B4XPages:
So can I use just a page? I just want to add webview, goback history and allowing localstorage
 
Upvote 0

asales

Expert
Licensed User
Longtime User
So can I use just a page? I just want to add webview, goback history and allowing localstorage
Yes. If you are using only the webview in a page. In this case the B4XMainPage.

There are several posts about using webview in the forum that can help you.
 
Upvote 0
Top