package com.example.helloandroid;
import java.io.File;
import android.os.AsyncTask;
import android.os.Environment;
import android.widget.Toast;
public class CheckTask extends AsyncTask<Void, Void, Boolean> {
protected Boolean doInBackground(Void... params) {
while (true) {
if (Environment.MEDIA_MOUNTED.equals(Environment
.getExternalStorageState())) {
// access external file
String f = Environment.getExternalStorageDirectory()
+ "/schedule.rtf";
File s = new File(f);
if (s.exists()) {
return true;
}
}
}
}
protected void onPostExecute(Boolean result) {
if (result == true) {
Toast.makeText(CheckTask.this, "Hello", Toast.LENGTH_SHORT).show();
}
}
}
我不断收到以下错误消息:Toast 类型中的方法 makeText(Context, CharSequence, int) 不适用于参数 (CheckTask, String, int)
我尝试搜索一些基本教程,他们以与上述相同的方式使用 Toast.makeText。我不确定出了什么问题。
谢谢你。