Quantcast
Channel: Appcelerator Developer Center Q&A Tag Feed (evaljs)
Viewing all articles
Browse latest Browse all 83

Android: EvalJS to get Cookie crash the app on emulator and device

$
0
0

Application type: mobile

Titanium SDK: Titanium SDK version: 1.8.1 (01/27/12 17:31 a24502a)

Platform & version: Android 2.2

Device: Android emulator / Device

Host Operating System: OSX 10.6

Titanium Studio: Titanium Studio, build: 1.0.8.201201262211

A simple test case:

  1. In the webview, when http://mail.live.com opens, input a windows live user name and password to sign in. Username: titest123@hotmail.com password: asd123

  2. After sign in, I believe there is a new cookie

  3. App crashes when it tries to do var cookie = webView.evalJS('document.cookie');

Code:

var win1= Ti.UI.createWindow({
    backgroundColor:'#ffffff',
    navBarHidden:true,
    exitOnClose:true
});
 
var label = Ti.UI.createLabel({
    color:'#000000',
    text:String.format(L('welcome'),'Titanium'), 
    height: '30',
    top: '10'
});
win1.add(label);
 
 
var webView = Ti.UI.createWebView({
            url:'http://mail.live.com',
            height:'300',
            width:'auto'});
win1.add(webView);
 
webView.addEventListener('load',function(e)
    {       
      var cookie = webView.evalJS('document.cookie'); 
      Ti.API.info('Page cookie' + cookie);
    });
When the code works perfectly on iOS emulator and device it crashes on android device and emulator and show the error

In App.js var cookie = webView.evalJS('document.cookie'); ** **Uncaught error: Only the original thread that created a view hierarchy can touch its view

Any idea?


Viewing all articles
Browse latest Browse all 83

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>