0

I'm developing chatting app in which I want to sync android native contact on first time login into my local database.

The problem is that in my onPerformSync method, i'm syncing native contact into local db but in the mean while, if user tries to login, screen frozen for 5 mins.

Can anyone give me idea how to prevent system to frozen screen, or if it's not possible so where should I sync my native contact into local db.

1 Answers1

0

You can use IntentService for this. I have also made the same functionality for my project. Here is the sample hope it will help.

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));

Thanks

Sandeep
  • 2,573
  • 3
  • 21
  • 28