0

私は 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) {

    }

}
4

2 に答える 2

0

アクティビティ クラスの埋め込みクラスとして使用している場合はImageUploadTask、次のようにすることができます。

MyActivityClass.this.activityfunction();

or 

MyActivityClass.this.activityFieldVariable;
于 2013-04-12T17:17:44.653 に答える