我试图删除数据库中的一个especific注册表一旦用户退出应用程序。 对于这个问题我叫伟驰theorically运行时的应用程序ID摧毁一个IntentService。 问题在于,尽管如预期和注册表不会被删除此意图不工作。 这里是如果你可以帮助代码。 IntentService:
public class FinIntentService extends IntentService{
String levelstring = "22";
int pid;
static String pids;
BroadcastReceiver batteryReceiver = null;
String url = "10.0.0.13";
private static String url_crear = "http://10.0.0.13/subida/create_candidato.php";
private static final String url_delete = "http://10.0.0.13/subida/delete_candidato.php";
JSONParser jsonParser = new JSONParser();
@SuppressLint("NewApi")
static String device_id = Build.SERIAL;
static String PDA = device_id.substring(device_id.length() - 6);
public FinIntentService() {
super("FinIntentService");
}
@Override
protected void onHandleIntent(Intent intent)
{
int success;
try {
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("id", Titulacion.getPID()));
JSONObject json = jsonParser.makeHttpRequest(
url_delete, "POST", params);
Log.d("Delete Product", json.toString());
success = json.getInt("success");
} catch (JSONException e) {
e.printStackTrace();
}
}
}
例如日志未达到
主要活动:
public void onDestroy(){
super.onDestroy();
Intent msgIntent = new Intent(Titulacion.this, FinIntentService.class);
startService(msgIntent);
}
我尝试过使用的AsyncTask,但我无法得到预期的效果时的onDestroy。 然而,在某些情况下(1出的30)的synctask做了它的任务。