【发布时间】:2014-07-08 09:39:49
【问题描述】:
如何在android中实现账号和web服务器之间的数据同步?
我创建了一个项目,我正在尝试创建自己的帐户,并且我想通过该帐户在特定时间间隔后获取服务器数据。到目前为止,我已经google了,我找到了这个useful link
这告诉我很多。但我无法清楚地知道为我的项目做什么。我当然会感谢任何帮助或建议。以下是我为创建帐户所做的工作:-
public void onClick(View arg0) {
// startActivity(new Intent(Settings.ACTION_ADD_ACCOUNT));
str1 = ed1.getText().toString();
str2 = ed2.getText().toString();
if ((str1.matches(""))||(!str1.contains("@myapp.com"))) {
Toast.makeText(MainActivity.this, "Invalid type of User email id!", Toast.LENGTH_SHORT).show();
return;
}
if (str2.matches("")) {
Toast.makeText(MainActivity.this, "You did not enter a password", Toast.LENGTH_SHORT).show();
return;
}
Account account = new Account(str1, "com.example.accountMy");
String password = str2;
AccountManager accountManager = AccountManager.get(context);
boolean success = accountManager.addAccountExplicitly(account, password, null);
if(success){
Toast.makeText(MainActivity.this, "Myapp Account Created!", Toast.LENGTH_LONG).show();
}else{
Toast.makeText(MainActivity.this, "Account is not Created!", Toast.LENGTH_LONG).show();
}
}});
我已经使用 Customauthenticator 和 AcountauthenticatorService 类来验证我的帐户。请指教。
【问题讨论】:
标签: android sql-server-2005 synchronization account android-syncadapter