这是我在服务中的代码,请让我知道我在哪里遗漏了一些东西。代码在其他设备中运行问题仅在 Redmi 设备中。
提前致谢。
public class AppLocationServices extends Service implements IAsyncTask{
@Override
public IBinder onBind(Intent arg0) {
return null;
}
@Override
public int onStartCommand(final Intent intent, final int flags,
final int startId) {
if(getBaseContext()!=null){
SessionManagement sessionManagement = new SessionManagement(getBaseContext());
if(sessionManagement.isLoggedIn() && !Util.IsOwner(Util.GetLocalStorage(sessionManagement))){
if(getBaseContext()!=null && intent.getExtras()!=null && intent.getExtras().getString("ClassName").equalsIgnoreCase(ReceiverLocationAlarm.class.getName())){
Util.SetOnReceiverLocationIntent(getBaseContext());
LocationProvider mLocationProvider = new LocationProvider(getBaseContext());
mLocationProvider.connect();
}
else if(getBaseContext()!=null && intent.getExtras()!=null && intent.getExtras().getString("ClassName").equalsIgnoreCase(SenderLocationAlarm.class.getName())){
Util.SetOnSenderLocationIntent(getBaseContext());
DataBaseHelper dataBaseHelper = new DataBaseHelper(getBaseContext());
if(dataBaseHelper.getFromGpsItem().size()>0)
new SendLocationToServer(getBaseContext(),AppLocationServices.this).execute();
}
}else {
LocationProvider mLocationProvider = new LocationProvider(getBaseContext());
mLocationProvider.disconnect();
Util.StopOnReceiverLocationIntent(getContext());
Util.StopOnSendLocationIntent(getContext());
stopSelf();
}
}
return Service.START_REDELIVER_INTENT;
}
@Override
public Context getContext() {
return getBaseContext();
}
@Override
public Fragment getFragment() {
return null;
}
@Override
public void OnPreExecute() {
}
@Override
public void OnPostExecute(String URL, JSONObject jsonObject) {
}
@Override
public void OnErrorMessage(String Message) {
}
@Override
public void onDestroy() {
super.onDestroy();
}
}