2

現在、Android と Dropbox に基づいてアプリケーションを作成しています。

APIキーに基づいて録音したオーディオをドロップボックスにアップロードしたいのですが、たくさん試しました。私は解決策を見つけることができないので、誰もがこの状況を克服するのを助けることができます.

これが私のコードです。このコードを使用して、画像キャプチャとビデオ キャプチャを実行しました。コードは正常に動作していましたが、オーディオ レコーダーに変換すると動作しません。返信いただきありがとうございます。

オーディオレコーダー機能: mAudio=(Button)findViewById(R.id.audio_button); mAudio.setOnClickListener(新しいOnClickListener() {

         public void onClick(View v) {
             Intent intent = new Intent();
             // Picture from camera

            intent.setAction(Audio.Media.RECORD_SOUND_ACTION);
            Uri fileUri = getOutputMediaFileUri(MEDIA_TYPE_AUDIO);
            intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, fileUri);


            Log.i(TAG, "Importing New Picture: " + mCameraFileName);
            try {
                startActivityForResult(intent, NEW_AUDIO);
            } catch (ActivityNotFoundException e) {
                showToast("There doesn't seem to be a camera.");
            }
        }
    });   

アップロード機能:

そうでなければ(requestCode == NEW_AUDIO){

        if (resultCode == Activity.RESULT_OK) {
            Uri uri = null;
            if (data != null) {
                uri = data.getData();
            }
            if (uri == null && mAudioFileName != null) {
                uri = Uri.fromFile(new File(mAudioFileName));
                Log.v("Audio Uri", uri.toString()+" "+uri.getPath());
            }
            File file = new File(mAudioFileName);
            Log.v("Audio file", ""+file.getPath());

            if (uri != null) {
                UploadFile upload = new UploadFile(Home.this, mApi, PHOTO_DIR, file);
                upload.execute();
            }
        //showToast("till capture");
   }
    else if(resultCode == RESULT_CANCELED)
    {
        uriAudio = null;
        Toast.makeText(Home.this,"Cancelled!",Toast.LENGTH_LONG).show();
    }
4

1 に答える 1

1

サイトで与えられた公式の例によると。これがお役に立てば幸いです。

FileInputStream inputStream = null;
try {
    File file = new File("/path/to/file.txt");
    inputStream = new FileInputStream(file);
    Entry newEntry = mDBApi.putFile("/testing.txt", inputStream,
            file.length(), null, null);
    Log.i("DbExampleLog", "The uploaded file's rev is: " + newEntry.rev);
} catch (DropboxUnlinkedException e) {
    // User has unlinked, ask them to link again here.
    Log.e("DbExampleLog", "User has unlinked.");
} catch (DropboxException e) {
    Log.e("DbExampleLog", "Something went wrong while uploading.");
} catch (FileNotFoundException e) {
    Log.e("DbExampleLog", "File not found.");
} finally {
    if (inputStream != null) {
        try {
            inputStream.close();
        } catch (IOException e) {}
    }
}
于 2013-02-09T13:30:08.120 に答える