appcelerator titan - Ti.App.Properties 不适用于 Android
我正在使用 appcelerator titan 创建一个(iphone/android)移动应用程序。我在使用 Ti.App.Properties 时遇到问题, 我想保存用户的登录数据(用户名和密码),我使用 Ti.App.Properties 的 getList 和 setList 方法在应用程序启动时获取和设置用户名和密码。它在 iPhone 上运行良好,但在 Android 上,应用程序启动时不会检索数据(用户名和密码)。 这是应用程序启动时执行的代码:
var userDataArray=[{title:'name',value:''},
{title:'password',value:''}];
if(Ti.App.Properties.hasProperty("userDataArray"))
{
userDataArray = Ti.App.Properties.getList("userDataArray");
}
else
{
Ti.App.Properties.setList("userDataArray",userDataArray);
}
if((Ti.App.Properties.getList("userDataArray")[0].value.length==0)||(Ti.App.Properties.getList("userDataArray")[1].value.length==0))//check if name, password have no values.. on android, this is always the case, which is not correct
{
//go to login page
}
else if((Ti.App.Properties.getList("userDataArray")[0].value.length>0)&&(Ti.App.Properties.getList("userDataArray")[1].value.length>0))//if both username and password exist
{
//start
}
谢谢
I am creating an (iphone/android) mobile app using appcelerator titanium. I have a problem using Ti.App.Properties,
I want to save the user's login data (username and password), I used Ti.App.Properties's getList and setList methods to get and set username and password at app startup. It is working fine on iPhone, but on android the data (username and password) are not retrieved at app startup.
here is the code that is executed at app startup :
var userDataArray=[{title:'name',value:''},
{title:'password',value:''}];
if(Ti.App.Properties.hasProperty("userDataArray"))
{
userDataArray = Ti.App.Properties.getList("userDataArray");
}
else
{
Ti.App.Properties.setList("userDataArray",userDataArray);
}
if((Ti.App.Properties.getList("userDataArray")[0].value.length==0)||(Ti.App.Properties.getList("userDataArray")[1].value.length==0))//check if name, password have no values.. on android, this is always the case, which is not correct
{
//go to login page
}
else if((Ti.App.Properties.getList("userDataArray")[0].value.length>0)&&(Ti.App.Properties.getList("userDataArray")[1].value.length>0))//if both username and password exist
{
//start
}
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我认为你的整体方法是有缺陷的,你不需要一个数组,只需要一张地图
i think your overall approach is flawed, you dont need an array just an map
两点说明:
two remarks :
我知道这已经很旧了,但今天仍然具有相关性,因为对钛的帮助并不多。我分两部分处理这个问题。
第 1 部分)在用户的凭据经过身份验证后...
第 2 部分)在使用登录窗口/弹出窗口/其他内容提示用户之前...
I know this is old, but it's still relevant today as there's not a huge amount of help with Titanium. I handle this in two parts.
Part 1) After the user's credentials have been authenticated...
Part 2) Before you prompt the user with the login window/popup/whatever...