Titanium.Network.online is not working on android emulator
Titanium.Network.online does not yield any开发者_开发百科 result on android emulator, may I know what is wrong? I have added
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.INTERNET" />
to tiapp.xml Below are my code. Thanks.
$('#login').click(function(){
var email = $('#email').val();
var password = $('#password').val();
Titanium.App.fireEvent('loginNow', {e:email, p:password});
return false;
});
Titanium.App.addEventListener('loginNow', function(data){
if(!Titanium.Network.online){
Titanium.API.info('connection is not ok');
}else{
Titanium.API.info('connection is ok');
var signingin = Titanium.UI.createActivityIndicator({
message: "Signing in.."
});
signingin.show();
}
});
We have found that the online attribute seems to work. One other item you can look at is the network type from Titanium.Network.networkType. It will return one of the following Titanium.Network constants:
- NETWORK_LAN
- NETWORK_MOBILE
- NETWORK_WIFI
- NETWORK_UNKNOWN
- NETWORK_NONE
If you get none or unknown, that may be another indicator that something is amiss.
精彩评论