如何在asynctask中等待ACTION DELETE操作

时间:2013-07-31 11:02:22

标签: android android-asynctask

我有以下代码:

private class UninstallAppTask extends AsyncTask<String, String, String> {
    @Override
    protected void onPreExecute() {
        Toast.makeText(getApplicationContext(), "Starting ", Toast.LENGTH_SHORT).show();
    }
    @Override
    protected String doInBackground(String... strings) {
        Uri uri = Uri.fromParts("package", mAppList.get(position).getPackageName(), null);

        Intent it = new Intent(Intent.ACTION_DELETE, uri);
        startActivityForResult(it, 2);
        return null;
    }
    @Override
    protected void onPostExecute(String s) {
        Thread t = new Thread(mLoadAppLoadAndSortAppList);
        t.start();
    }
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == RESULT_OK)
        Toast.makeText(getApplicationContext(), "Succesfull", Toast.LENGTH_LONG).show();
}

当我调用UninstallAppTask时,首先写入“Starting”然后运行doInBackground但不等待activityresult写入“Succesfull”。我想等待关闭卸载屏幕,然后必须写“Succesfull”。

我该怎么办?

0 个答案:

没有答案