Первое приложение, которое у меня есть, содержит следующий код в действии:
Код: Выделить всё
Intent intent = new Intent("com.android.testintent.app.bcast");
intent.setData(contentUri);
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
sendBroadcast(intent);
Код: Выделить всё
android:name="android.support.v4.content.FileProvider"
android:authorities="com.android.provider.DataSharing"
android:exported="false"
android:grantUriPermissions="true" >
contentUri = FileProvider.getUriForFile(getApplicationContext(),
"com.android.provider.DataSharing", /* file's path */);
// file's path is correct - I have tested it with activity
Код: Выделить всё
Код: Выделить всё
Toast.makeText(context, "Bcast - received", Toast.LENGTH_LONG).show();
Uri uri = intent.getData();
if(uri != null) {
try {
InputStream inputStream = context.getContentResolver().openInputStream(uri);
}
catch (Exception e) {
Log.d("TEST", "Bcast - exception : " + e);
}
}
Может ли кто-нибудь указать причину такого поведения?
Изменить:
Я отредактировал приемник:
Код: Выделить всё
Код: Выделить всё
An intent that contains both a URI and a MIME type (either explicit or
inferable from the URI) passes the MIME type part of the test only if
that type matches a type listed in the filter. It passes the URI
part of the test either if its URI matches a URI in the filter or if
it has a content: or file: URI and the filter does not specify a URI.
In other words, a component is presumed to support content: and file:
data if its filter lists only a MIME type.
Код: Выделить всё
D/TEST﹕ Bcast - exception : java.lang.SecurityException: Permission Denial:
opening provider android.support.v4.content.FileProvider from
ProcessRecord{529a7b60 1593:com.android.testintent.app/u0a55}
(pid=1593, uid=10055) that is not exported from uid 10059
Что я могу сделать, чтобы решить эту проблему?
Подробнее здесь: https://stackoverflow.com/questions/249 ... -broadcast
Мобильная версия