내 코드가 작동하지 않는 이유를 모르겠습니다. 나는 많은 동일한 문제를 읽었지 만, 이것은 대부분의 경우 올바른 해결책이지만, 나를 위해 일하는 것이 아닙니다.Dismiss() 메소드로 ProgressDialog를 멈출 수 없습니다.
public class SavingAsync extends AsyncTask<String, String, String> {
private static final String TAG = "DrawView";
private ProgressDialog pd;
private Context context;
private File saveFile;
private Bitmap bitmap;
public SavingAsync(Context c, File sF, Bitmap b) {
context = c;
saveFile = sF;
bitmap = b;
}
@Override
protected void onPostExecute(String result) {
pd.dismiss();
super.onPostExecute(result);
}
@Override
protected void onPreExecute() {
pd = new ProgressDialog(context);
ProgressDialog.show(context, "", "Saving...");
super.onPreExecute();
}
@Override
protected String doInBackground(String... params) {
OutputStream stream;
try {
stream = new FileOutputStream(saveFile);
bitmap.compress(CompressFormat.PNG, 80, stream);
stream.close();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}
비트 맵이 성공적으로 저장되지만해서 ProgressDialog 영원히 실행 : 내 AsyncTask를은 다음과 같습니다/
체크 아웃 http://developer.android.com/reference/android/app/DialogFragment.html –