android - How to get Locations using the FusedLocationApi even if the phone goes sleep? -


i have service work on getting device location in order send on server.

in order location i'm using google's locationservices.fusedlocationapi api following:

intent intent = new intent(this, locationintentservice.class); mlocationpendingintent =     pendingintent.getservice(this, 0, intent,          pendingintent.flag_update_current); locationrequest request = locationrequest.create().setinterval(1500).setpriority(locationrequest.priority_high_accuracy); mlastlocation = locationservices.fusedlocationapi.getlastlocation(googleapiclient); locationservices.fusedlocationapi.requestlocationupdates(googleapiclient, request, mlocationpendingintent); 

the above works fine, excepts when phone goes sleep, means of screen automatically going off or manually pushing power button in order so.

so there's problem, gps stops getting location results though service still up; not yet eaten system.

i thinking problem might actual gps gets turned off system save battery don't know how set not stop sending me locations though phone idle.

i thought on setting repeating alarm on alarmmanager callback wakefulbroadcastreceiver implementation doing battery consuming , unfeasible since seems system capping alarm intervals reason since android 5.1.