android同步本地联系人进入本地数据库

时间:2015-05-05 09:20:26

标签: android android-contentprovider android-syncadapter

我正在开发聊天应用,我想在第一次登录我的本地数据库时同步Android原生联系人。

问题在于,在我的onPerformSync方法中,我将本地联系人同步到本地数据库,但同时,如果用户尝试登录,屏幕冻结5分钟。

任何人都可以告诉我如何防止系统冻结屏幕,或者如果不可能,那么我应该将我的本地联系人同步到本地数据库。

1 个答案:

答案 0 :(得分:0)

您可以使用IntentService。我也为我的项目提供了相同的功能。 这是希望它会有所帮助的样本。

public class ManagePhoneContacts  extends IntentService {

public ManagePhoneContacts()
{
    super("ManageContactsService");

}

@Override
protected void onHandleIntent(Intent workIntent) {
   getContacts();

}

private void getContacts()
{
    //your code
}   
}

//starting service where need to start
startService(new Intent(context, ManagePhoneContacts.class));

由于

相关问题