Ich habe einen Dienst, der Fehler an eine URL sendet, dieser Dienst gute Arbeit in anderen Diensten, aber wenn ich einen Fehler in Selbst habe, fällt in Schleifen, die sehr schlecht ist.Android - Service fällt in Schleife?
public class Error_Service extends Service {
Context context;
RequestPackage RP;
String Value;
G g;
Internet_Connect IC;
public final static String MY_ACTION_E = "MY_ACTION_E";
@Override
public void onCreate() {
context = this;
IC = new Internet_Connect(context);
}
@Nullable
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
handleStart(intent, startId);
return super.onStartCommand(intent, flags, startId);
}
@Override
public void onDestroy() {
super.onDestroy();
}
void handleStart(Intent intent, int startId) {
String ww = null;
try {
Log.i("ASDASASDAS",ww);
}catch (Exception e){
g = new G();
new GetErrors(context);
Exception_String EX =new Exception_String();
GetErrors.SendErrors("43", EX.ValueEX(e), g.VersionCode());
return;
}
RP = (RequestPackage) intent.getSerializableExtra("MyValue");
try {
Value = new ErrorService().execute(RP).get();
} catch (InterruptedException e) {
e.printStackTrace();
if (IC.getConnectivityStatus()) {
g = new G();
new GetErrors(context);
Exception_String EX = new Exception_String();
GetErrors.SendErrors("43", EX.ValueEX(e), g.VersionCode());
}
} catch (ExecutionException e) {
e.printStackTrace();
if (IC.getConnectivityStatus()) {
g = new G();
new GetErrors(context);
Exception_String EX = new Exception_String();
GetErrors.SendErrors("43", EX.ValueEX(e), g.VersionCode());
}
} finally {
ThreadFinish_Send thread_finish = new ThreadFinish_Send();
thread_finish.start();
}
}
public class ErrorService extends AsyncTask<RequestPackage,String,String>{
@Override
protected String doInBackground(RequestPackage... params) {
BufferedReader reader = null;
String uri = params[0].getUri();
if (params[0].getMethod().equals("GET")) {
uri += "?" + params[0].getEncodedParams();
}
try {
URL url = new URL(uri);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod(params[0].getMethod());
StringBuilder sb = new StringBuilder();
reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String line;
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
return sb.toString();
} catch (Exception e) {
e.printStackTrace();
if (IC.getConnectivityStatus()) {
g = new G();
new GetErrors(context);
Exception_String EX = new Exception_String();
GetErrors.SendErrors("43", EX.ValueEX(e), g.VersionCode());
return null;
}
return null;
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e) {
e.printStackTrace();
if (IC.getConnectivityStatus()) {
g = new G();
new GetErrors(context);
Exception_String EX = new Exception_String();
GetErrors.SendErrors("43", EX.ValueEX(e), g.VersionCode());
return null;
}
return null;
}
}
}
}
}
public class ThreadFinish_Send extends Thread{
@Override
public void run() {
Intent intent = new Intent();
intent.setAction(MY_ACTION_E);
intent.putExtra("MVE",Value);
sendBroadcast(intent);
stopSelf();
}
}
}
Was kann ich tun?