0

我有以下代码:

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”。我想等待关闭卸载屏幕,然后必须写“成功”。

我能怎么做 ?

4

0 回答 0