Android Question Open another app from own app

harinder

Active Member
Licensed User
Longtime User
Hello..I am stuck !! I have my app whose primary function is to fill into a database and populate a flexitable after each entry. One of the secondary functions is to fill few of the database entries into a form of another app by first opening it, logging into it and then submitting it online. The app has forms with text boxes which need to be automatically filled as per the current entry, and also has radio buttons and dropdowns out of which appropriate choices need to be selected as per current entry.
Can somebody point me to an example or a possible lead to start with. Is Intent possible through my app, but I don't have access to coding of other app so intent filter will be an issue. Any heads up will be appreciated. Thanks..
 

harinder

Active Member
Licensed User
Longtime User
It is not possible, unless the other app exposes such features with intents.
Ok Erel..I tried to use following post of @warwound on webviewlogin to login to the parent website of this app:
B4X:
#Region  Project Attributes
    #ApplicationLabel: B4A Example
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
    #BridgeLogger:True
#End Region

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

Sub Process_Globals

End Sub

Sub Globals
    Dim LogonUrl As String="https://www.dgca.gov.in/digigov-portal/jsp/dgca/common/login.jsp"
    Dim WebView1 As WebView
    Dim WebViewExtras1 As WebViewExtras
End Sub

Sub Activity_Create(FirstTime As Boolean)
    WebView1.Initialize("WebView1")
    Activity.AddView(WebView1, 0, 0, 100%x, 100%y)
    WebViewExtras1.Initialize(WebView1)
    Dim WebChromeClient1 As DefaultWebChromeClient
    WebChromeClient1.Initialize("WebChromeClient1")
    WebViewExtras1.SetWebChromeClient(WebChromeClient1)
    WebView1.LoadUrl(LogonUrl)
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub


Sub WebView1_PageFinished (Url As String)
    Log("WebView1_PageFinished")
    If Url=LogonUrl Then
        Dim Javascript As StringBuilder
        Javascript.Initialize
        Javascript.Append("document.forms.captcha_val.username.value='My_username';")
        Javascript.Append("document.forms.captcha_val.password.value='My_password';")
        '    uncomment next line to auto submit the logon form
        '    be careful - if logon fails then the webpage will be reloaded
        '    and an infinite loop of failed logons is likely
            Javascript.Append("document.forms.captcha_val.submit();")
        WebViewExtras1.ExecuteJavascript(Javascript.ToString)
        Log("Form updated")
    End If
End Sub

But I am not able to login.. Log is appended below:
B4X:
Logger connected to:  samsung SM-F926B
--------- beginning of main
--------- beginning of system
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
WebView1_PageFinished
Form updated
Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/. in https://trakcarelabwebview.nhls.ac.za/csp/broker/cspxmlhttp.js (Line: 149)
** Activity (main) Pause, UserClosed = true **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/. in https://chatbot.dgca.gov.in/UNFYD-Webchat/Unfyd-Chat.js?TenantId=1&ChannelName=Webchat&ChannelSubType=TCS2 (Line: 95)
Uncaught TypeError: e.indexOf is not a function in https://www.dgca.gov.in/digigov-portal/assets/DGCA/libs/js/jquery.min.js?v=1.3 (Line: 2)
Function Name => ControllerJS Error; JS File => Unfyd-ChatContorller.js; Error Message => Error while loading angular controller; Data Object = >  TypeError: Cannot read properties of null (reading 'getItem') in https://chatbot.dgca.gov.in/UNFYD-Webchat/Scripts/Unfyd-JS/Unfyd-CommonJS.js?v=2?v=1 (Line: 16)
Script loaded successfully... in https://chatbot.dgca.gov.in/UNFYD-Webchat/Unfyd-Chat.js?TenantId=1&ChannelName=Webchat&ChannelSubType=TCS2 (Line: 282)
Uncaught TypeError: Cannot read properties of null (reading 'getItem') in https://chatbot.dgca.gov.in/UNFYD-Webchat/Scripts/Unfyd-JS/Unfyd-ChatService.js?v=25?v=1 (Line: 341)
WebView1_PageFinished
Form updated
TypeError: scope.PopOverClick is not a function in https://chatbot.dgca.gov.in/UNFYD-Webchat/Scripts/angular-1.6.9.min.js?v=1 (Line: 124)
Uncaught TypeError: Cannot read properties of undefined (reading 'username') in https://www.dgca.gov.in/digigov-portal/jsp/dgca/common/login.jsp (Line: 1)
Uncaught TypeError: Cannot read properties of null (reading 'getItem') in https://chatbot.dgca.gov.in/UNFYD-Webchat/Scripts/Unfyd-JS/Unfyd-CommonJS.js?v=2?v=1 (Line: 97)

What changes do I need to make ?
How do I get rid of the chatbot interface that pops up and refuses to go?
Also, I understand that after injecting username and password, the user can input the captcha code as he sees it, to enable final login and enable autofill of form from next page onwards as desired in my opening post?
Thanks
 
Last edited:
Upvote 0
Top