허가 거부하에 대한 첨부 파일을 gmail 안드로이드

0

질문

When I 버튼을 누르면,나를 보내고 싶 json 파일 내부에 장치를 통해 메일입니다. 치는 Gmail 면,나는 오류"사용 권한을 위해 첨부파일". 어떻게 이 문제를 해결하는가?

manifest:

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_INTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

내 코드


 sendgmailButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String filepath = "/data/data/com.example.newgen/files/jsonexample.json";


                        Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
                        emailIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
                        emailIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
                        emailIntent.setType("application/json");
                         emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]
                                {"[email protected]"});
                        emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
                                "Test Subject");
                        emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,
                                "go on read the emails");
               
                        emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://"+ filepath));


        
                        startActivity(Intent.createChooser(emailIntent, "Send mail..."));


            }
        });


android android-intent gmail java
2021-11-24 06:47:21
1

최고의 응답

0

기 때문에 전자 메일 응용 프로그램지 액세스할 수 있는 권한이 있는 파일로서 귀하의 디렉토리 구조. 그리고 당신이 무엇을 하고 있을 출시하는 다른 응용 프로그램과 전달하는 파일 이름에 끝났습니다. 을 사용해야 합 FileProvider 이 참조하십시오 https://developer.android.com/reference/androidx/core/content/FileProvider

2021-11-24 06:51:53

감사합니다. 내가 문제를 해결 FiloProvider
Muratcan Yıldız

다른 언어로

이 페이지는 다른 언어로되어 있습니다

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................