I have one service(BackgoundService)
, one intent service (MyIntentService)
and one process
in my android app. UI hangs i.e. freezes completely when all three are running but it becomes so responsive when I stop the Intent Service.
Also I am running the BackgroundService in a worker thread and documentation says that Intent Service runs in a separate worker thread by default.
I don't get why my ui thread is still getting blocked when all other operations ,services are running in separate threads.
Intent service
public class MyIntentService extends IntentService {
public static String ACTION ="com.example.mediaapp.prototypingcanvas.MyIntentService.DONE_Processing";
public MyIntentService(){
super("MyIntentService");
}
DBRepo dbRepo;
WebRepo webRepo;
FileRepo fileRepo;
@Override
protected void onHandleIntent(Intent intent) {
//Activity Types ; 1=uploadSurvey; 2=downloadQre; 3=download survey for review; 4=sample download; 5=projectlistdownload
webRepo = new WebRepo(this);
fileRepo = new FileRepo();
int queueID = intent.getIntExtra("ID", 0);
dbRepo = new DBRepo(getApplicationContext());
dbRepo.updateQueue(queueID);
List<String> filesList;
int activityType = intent.getIntExtra("ActivityType", 0);
// int projectID = intent.getIntExtra("ProjectID",0);
String userName = intent.getStringExtra("UserName");
String ProjectGUID = intent.getStringExtra("ProjectGUID");
String projectName = intent.getStringExtra("ProjectName");
int response = -1;
Log.i("activitytype", activityType + "");
if (activityType == 1) {
filesList = new ArrayList<>();
filesList = fileRepo.list(projectName);
for (String fileName : filesList) {
webRepo.SyncData("http://test.cloud.rebuscode.com/api/api/v2/respondent/SyncData/" + projectName + "/" + fileName + "/true");
}
Log.i("activity type", activityType + "");
response = 1;
} else if (activityType == 2) {
Log.i("activity type", activityType + "");
response = 0;
} else if (activityType == 3) {
Log.i("activity type", activityType + "");
//webRepo.DownloadQuestionnaire("http://test.cloud.rebuscode.com/api/api/v2/respondent/DownloadQuestionnaireForTab/" + projectGuid + "/" + projectName,projectName);
fileRepo.unzip("Splash/and.zip");
} else if (activityType == 4) {
Log.i("activity type", activityType + "");
response = 1;
} else if (activityType == 5) {
Log.i("activity type", activityType + "");
response = 0;
} else {
Log.i("activity type", activityType + "");
}
// processing done here….
//delete row from Queue table and broadcast
dbRepo.deleteQueue(queueID);
Intent broadcastIntent = new Intent(ACTION);
broadcastIntent.putExtra("Response", response);
broadcastIntent.putExtra("ActivityType", activityType);
broadcastIntent.putExtra("UserName", userName);
broadcastIntent.putExtra("ID", queueID);
broadcastIntent.putExtra("ProjectGuid", ProjectGUID);
sendBroadcast(broadcastIntent);
}
}
can anyone suggest why its blocking my ui thread???