2017-04-08 17 views
1

アンドロイドのアプリケーションを実行すると、Androidは致命的な例外を表示し、別のアプリケーションとデータを共有します。ノーガットの下で完璧に走ります。アンドロイドは別のアプリケーションでコンテンツを共有するとエラーを表示します

は、ここに私のコード

Intent sendIntent = new Intent(Intent.ACTION_SEND); 
    sendIntent.putExtra(Intent.EXTRA_SUBJECT, "Student Details of " + currentDate); 
    sendIntent.putExtra(Intent.EXTRA_STREAM, u1); 
    sendIntent.setType("text/plain"); 
    startActivity(sendIntent); // Gives error on this line 

これはエラーショーです。

04-08 18:31:38.371 18464-18464/manager.attendance.com E/AndroidRuntime: FATAL EXCEPTION: main 
                    Process: manager.attendance.com, PID: 18464 
                    java.lang.RuntimeException: Failure delivering result ResultInfo{[email protected]:requestPermissions:, request=5, result=-1, data=Intent { act=android.content.pm.action.REQUEST_PERMISSIONS (has extras) }} to activity {manager.attendance.com/manager.attendance.com.activity.MainActivity}: android.os.FileUriExposedException: file:///storage/emulated/0/Exported%20Data/Data-08-Apr-2017.csv exposed beyond app through ClipData.Item.getUri() 
                     at android.app.ActivityThread.deliverResults(ActivityThread.java:4094) 
                     at android.app.ActivityThread.handleSendResult(ActivityThread.java:4137) 
                     at android.app.ActivityThread.-wrap20(ActivityThread.java) 
                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1529) 
                     at android.os.Handler.dispatchMessage(Handler.java:102) 
                     at android.os.Looper.loop(Looper.java:154) 
                     at android.app.ActivityThread.main(ActivityThread.java:6123) 
                     at java.lang.reflect.Method.invoke(Native Method) 
                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867) 
                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:757) 
                    Caused by: android.os.FileUriExposedException: file:///storage/emulated/0/Exported%20Data/Data-08-Apr-2017.csv exposed beyond app through ClipData.Item.getUri() 
                     at android.os.StrictMode.onFileUriExposed(StrictMode.java:1813) 
                     at android.net.Uri.checkFileUriExposed(Uri.java:2360) 
                     at android.content.ClipData.prepareToLeaveProcess(ClipData.java:832) 
                     at android.content.Intent.prepareToLeaveProcess(Intent.java:8957) 
                     at android.content.Intent.prepareToLeaveProcess(Intent.java:8942) 
                     at android.app.Instrumentation.execStartActivity(Instrumentation.java:1583) 
                     at android.app.Activity.startActivityForResult(Activity.java:4228) 
                     at android.support.v4.app.BaseFragmentActivityJB.startActivityForResult(BaseFragmentActivityJB.java:50) 
                     at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:79) 
                     at android.app.Activity.startActivityForResult(Activity.java:4187) 
                     at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:859) 
                     at android.app.Activity.startActivity(Activity.java:4515) 
                     at android.app.Activity.startActivity(Activity.java:4483) 
                     at manager.attendance.com.activity.MainActivity.exportToCsvAndSend(MainActivity.java:171) 
                     at manager.attendance.com.activity.MainActivity.onRequestPermissionsResult(MainActivity.java:191) 
+0

https://stackoverflow.com/a/38203793/115145文書化されている。この

startActivity(Intent.createChooser(shareIntent, getResources().getText(R.string.send_to))); 

代わりの

startActivity(sendIntent); 

をお試しください – CommonsWare

答えて

関連する問題