user1221447
user1221447

Reputation:

Passing values from a web page to your app - Android / Blackberry

Just wondering if the following is possible:

(A) App loads a login page hosted on remote server using webview (Android) / browserfield (BBerry) (B) Authentication takes place at the web page housed in webview / browserfield (C) After successful login - some params are passed back from the webpage and used in subsequent screens in the app.

Thanks in advance

Upvotes: 0

Views: 693

Answers (2)

Hrushikesh Salkade
Hrushikesh Salkade

Reputation: 308

for blackberry

  1. Write a Javascript function in your html page which will pass data after login.

//sample code in html.

function passData() {
            makeblackberry.pass('Hello','1234');
        }

// in blackberry class
_browserField.extendScriptEngine("makeblackberry.pass",
                    new ScriptableFunction() {
                public Object invoke(Object thiz,final Object[] args)
                {
                              // here args will give you params passed by javascript                       
                              //function
                              // args[0] = Hello and args[1] = 1234
                              //TODO do your task here...

                      return thiz;
                }
            });

Upvotes: 0

Mirko Lindner
Mirko Lindner

Reputation: 628

on android:

You can expose javascript interfaces on your webview. This allows you to define a callback in java and call it from the page loaded after the user logged in.

Flow:

  1. create your interface with addJavascriptInterface [1]

  2. app opens webview

  3. user logs in

  4. webserver returns a page with js calling your exposed interface passing the variables/values you want

  5. application continues

[1] http://developer.android.com/reference/android/webkit/WebView.html#addJavascriptInterface(java.lang.Object, java.lang.String)

Upvotes: 1

Related Questions