2014-02-06 1 views
2

내 응용 프로그램에서 저장 한 오디오 파일을 공유하려고합니다. 파일이 미디어 저장소에 추가되므로 모든 응용 프로그램에서 해당 파일에 액세스 할 수 있습니다.Intent.ACTION_SEND를 사용하여 파일을 공유하면 BBM에서 액세스가 거부됩니다.

Intent mediaScannerIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); 
    Uri fileContentUri = Uri.fromFile(finalFile); 
    mediaScannerIntent.setData(fileContentUri); 
    this.sendBroadcast(mediaScannerIntent); 

내가 다른 앱에 파일을 공유 할 수 Intent.ACTION_SEND를 사용

public void shareRecording(View view) { 
    Intent i = new Intent(Intent.ACTION_SEND); 
    i.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); 
    i.setType("audio/mp3"); 
    i.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///" + recording.getFilePath())); 
    try { 
     startActivity(Intent.createChooser(i, "Share " + recording.getName())); 
    } catch (android.content.ActivityNotFoundException ex) { 
     Toast.makeText(this, "There are no app installed to share your audio file.", Toast.LENGTH_SHORT).show(); 
    } 
} 

모든 Gmail은, 야후 메일, WHATSAPP, ... BBM을 제외하고 같은 모든 응용 프로그램과 좋은 작업이 있습니다 접근 불가. BBM에서 작동하게하려면 어떻게해야합니까?

도움 주셔서 감사합니다.

는 UPDATE :

나는

Uri fileUri = Uri.parse("content://" + recording.getFilePath()); 

대신

Uri fileUri = Uri.parse("file:///" + recording.getFilePath()); 

를 사용하고는 BBM에 근무하지만

그래서 참 차이점은 무엇 인접 애플 리케이션

하지 URI는 "file : ///"및 "co"로 구문 분석됩니다. ntent : // "? 그리고 모든 앱에서 공유 기능을 사용하려면 어떻게해야합니까?

Error on BBM

답변

2

해결책은 URI 객체를 초기화하는 실제 파일을 사용하는 것이다.

File recordingFile = new File(recording.getFilePath()); 
Uri fileUri = Uri.fromFile(recordingFile); 

파일을 공유 할 수있는 모든 앱에서 작동했습니다.