我将在 java 中迈出第一步:我有以下问题。从我的受保护类“onActivityResult”中,我需要在我的类“ImageUploadTask”中有字符串。我怎样才能做到这一点?
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) {
case PICK_IMAGE:
if (resultCode == Activity.RESULT_OK) {
Uri selectedImageUri = data.getData();
String filePath = null;
try {
...
} else if (filemanagerstring != null) {
filePath = filemanagerstring;
}
if (filePath != null) {
decodeFile(filePath);
// get fileName //
String fileName = new File(filePath).getName();
Log.e(TAG, "Filename:" + fileName);
}
break;
default:
}
}
class ImageUploadTask extends AsyncTask<Void, Void, String> {
private static final String TAG = "GalleryPreviewView";
@Override
protected String doInBackground(Void... unsued) {
try {
....
Log.e(TAG, "Filename:" + fileName);
}
}
@Override
protected void onProgressUpdate(Void... unsued) {
}
}