Why did `Intent.createChooser(shareIntentWithJpgFileName)` quit working?
Image File No Longer Passed Through Chooser
The code startActivity(intent.createChooser(shareIntentWithJpgFileName))
had been working fine in my application for years, but I noticed about a month ago that it no longer passes the image file to the application that the user selects in the chooser dialog. I suspect Android OS security shuffling (again!), but not sure how to proceed.
If the user selects any number of choices in the chooser dialog, the application opens, but doesn't show the .jpg
that was part of the intent. If the user selects Google Drive, I get a hint of what's wrong through it's toast:
Upload unsuccessful: request contained no data
The Code that Used To Work:
String fileName = data.getStringExtra(EXTRA_FILENAME);
Log.v(TAG, "Starting Share intent. fileName: " + fileName); //This shows fileName: /storage/emulated/0/dcim/DalesApp/IMG_20190103_142555_8445288886207383328.jpg
Intent shareIntentWithJpgFileName = new Intent(Intent.ACTION_SEND);
shareIntentWithJpgFileName.setType("image/jpeg");
File filePassedIn = new File(fileName);
Log.v(TAG, "exists: " + filePassedIn.exists() + " canRead: " + filePassedIn.canRead()); // Result is exists: true canRead: true. Thanks Mark!
shareIntentWithJpgFileName.putExtra(MediaStore.EXTRA_OUTPUT, FileProvider.getUriForFile(this, BuildConfig.APPLICATION_ID + ".provider", filePassedIn));
shareIntentWithJpgFileName.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(Intent.createChooser(shareIntentWithJpgFileName, "Share Image"));
Also, I have this as part of the AndroidManifest.xml
:
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths"/>
</provider>
And this is also in the AndroidManifest.xml
:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Question
Why has this stopped working and how can I get it working again?
I would be pleased to maintain/update/fix/correct/delete this question, so please give me guidance if you find it unsatisfactory for any reason.
Addendum
I changed the filter in Logcat
from Show only selected application to No Filters and was able to see logging from all applications. There were probably 50 or so lines that popped-up. It's hard to tell which items are applicable to the intent I started, but some are obviously from the intent I started (selected Google Drive in the chooser dialog). I picked a few more interesting logging entries:
I/ActivityManager: START u0 {act=android.intent.action.SEND typ=image/jpeg flg=0xb080001 cmp=com.google.android.apps.docs/.shareitem.UploadMenuActivity (has extras)} from uid 10196
E/SchedPolicy: open of /dev/cpuctl/bg_non_interactive/tasks failed: No such file or directory
I/ActivityManager: Start proc 12705:com.google.android.apps.docs/u0a92 for activity com.google.android.apps.docs/.shareitem.UploadMenuActivity
E/AsyncTask #3-DataSourceHelper: Uploading single file but neither EXTRA_STREAM nor EXTRA_TEXT is specified.
E/main-UploadMenuActivity: No files requested to be uploaded: android.intent.action.SEND
I/LaunchCheckinHandler: Displayed com.google.android.apps.docs/.shareitem.UploadMenuActivity,cp,ca,570
My next step is checking into "EXTRA_STREAM", which I haven't done yet, but I might be close to solving this on my own.
android android-security android-intent-chooser
add a comment |
Image File No Longer Passed Through Chooser
The code startActivity(intent.createChooser(shareIntentWithJpgFileName))
had been working fine in my application for years, but I noticed about a month ago that it no longer passes the image file to the application that the user selects in the chooser dialog. I suspect Android OS security shuffling (again!), but not sure how to proceed.
If the user selects any number of choices in the chooser dialog, the application opens, but doesn't show the .jpg
that was part of the intent. If the user selects Google Drive, I get a hint of what's wrong through it's toast:
Upload unsuccessful: request contained no data
The Code that Used To Work:
String fileName = data.getStringExtra(EXTRA_FILENAME);
Log.v(TAG, "Starting Share intent. fileName: " + fileName); //This shows fileName: /storage/emulated/0/dcim/DalesApp/IMG_20190103_142555_8445288886207383328.jpg
Intent shareIntentWithJpgFileName = new Intent(Intent.ACTION_SEND);
shareIntentWithJpgFileName.setType("image/jpeg");
File filePassedIn = new File(fileName);
Log.v(TAG, "exists: " + filePassedIn.exists() + " canRead: " + filePassedIn.canRead()); // Result is exists: true canRead: true. Thanks Mark!
shareIntentWithJpgFileName.putExtra(MediaStore.EXTRA_OUTPUT, FileProvider.getUriForFile(this, BuildConfig.APPLICATION_ID + ".provider", filePassedIn));
shareIntentWithJpgFileName.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(Intent.createChooser(shareIntentWithJpgFileName, "Share Image"));
Also, I have this as part of the AndroidManifest.xml
:
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths"/>
</provider>
And this is also in the AndroidManifest.xml
:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Question
Why has this stopped working and how can I get it working again?
I would be pleased to maintain/update/fix/correct/delete this question, so please give me guidance if you find it unsatisfactory for any reason.
Addendum
I changed the filter in Logcat
from Show only selected application to No Filters and was able to see logging from all applications. There were probably 50 or so lines that popped-up. It's hard to tell which items are applicable to the intent I started, but some are obviously from the intent I started (selected Google Drive in the chooser dialog). I picked a few more interesting logging entries:
I/ActivityManager: START u0 {act=android.intent.action.SEND typ=image/jpeg flg=0xb080001 cmp=com.google.android.apps.docs/.shareitem.UploadMenuActivity (has extras)} from uid 10196
E/SchedPolicy: open of /dev/cpuctl/bg_non_interactive/tasks failed: No such file or directory
I/ActivityManager: Start proc 12705:com.google.android.apps.docs/u0a92 for activity com.google.android.apps.docs/.shareitem.UploadMenuActivity
E/AsyncTask #3-DataSourceHelper: Uploading single file but neither EXTRA_STREAM nor EXTRA_TEXT is specified.
E/main-UploadMenuActivity: No files requested to be uploaded: android.intent.action.SEND
I/LaunchCheckinHandler: Displayed com.google.android.apps.docs/.shareitem.UploadMenuActivity,cp,ca,570
My next step is checking into "EXTRA_STREAM", which I haven't done yet, but I might be close to solving this on my own.
android android-security android-intent-chooser
1
I assume you've done some sanity checks onfilePassedIn
i.e.File::exists
,File::canRead
etc, just to rule this out upfront?
– Mark Keen
Jan 3 at 19:57
Thanks Mark. I added a debug line to the code. Both returned true.
– Dale
Jan 3 at 20:04
add a comment |
Image File No Longer Passed Through Chooser
The code startActivity(intent.createChooser(shareIntentWithJpgFileName))
had been working fine in my application for years, but I noticed about a month ago that it no longer passes the image file to the application that the user selects in the chooser dialog. I suspect Android OS security shuffling (again!), but not sure how to proceed.
If the user selects any number of choices in the chooser dialog, the application opens, but doesn't show the .jpg
that was part of the intent. If the user selects Google Drive, I get a hint of what's wrong through it's toast:
Upload unsuccessful: request contained no data
The Code that Used To Work:
String fileName = data.getStringExtra(EXTRA_FILENAME);
Log.v(TAG, "Starting Share intent. fileName: " + fileName); //This shows fileName: /storage/emulated/0/dcim/DalesApp/IMG_20190103_142555_8445288886207383328.jpg
Intent shareIntentWithJpgFileName = new Intent(Intent.ACTION_SEND);
shareIntentWithJpgFileName.setType("image/jpeg");
File filePassedIn = new File(fileName);
Log.v(TAG, "exists: " + filePassedIn.exists() + " canRead: " + filePassedIn.canRead()); // Result is exists: true canRead: true. Thanks Mark!
shareIntentWithJpgFileName.putExtra(MediaStore.EXTRA_OUTPUT, FileProvider.getUriForFile(this, BuildConfig.APPLICATION_ID + ".provider", filePassedIn));
shareIntentWithJpgFileName.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(Intent.createChooser(shareIntentWithJpgFileName, "Share Image"));
Also, I have this as part of the AndroidManifest.xml
:
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths"/>
</provider>
And this is also in the AndroidManifest.xml
:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Question
Why has this stopped working and how can I get it working again?
I would be pleased to maintain/update/fix/correct/delete this question, so please give me guidance if you find it unsatisfactory for any reason.
Addendum
I changed the filter in Logcat
from Show only selected application to No Filters and was able to see logging from all applications. There were probably 50 or so lines that popped-up. It's hard to tell which items are applicable to the intent I started, but some are obviously from the intent I started (selected Google Drive in the chooser dialog). I picked a few more interesting logging entries:
I/ActivityManager: START u0 {act=android.intent.action.SEND typ=image/jpeg flg=0xb080001 cmp=com.google.android.apps.docs/.shareitem.UploadMenuActivity (has extras)} from uid 10196
E/SchedPolicy: open of /dev/cpuctl/bg_non_interactive/tasks failed: No such file or directory
I/ActivityManager: Start proc 12705:com.google.android.apps.docs/u0a92 for activity com.google.android.apps.docs/.shareitem.UploadMenuActivity
E/AsyncTask #3-DataSourceHelper: Uploading single file but neither EXTRA_STREAM nor EXTRA_TEXT is specified.
E/main-UploadMenuActivity: No files requested to be uploaded: android.intent.action.SEND
I/LaunchCheckinHandler: Displayed com.google.android.apps.docs/.shareitem.UploadMenuActivity,cp,ca,570
My next step is checking into "EXTRA_STREAM", which I haven't done yet, but I might be close to solving this on my own.
android android-security android-intent-chooser
Image File No Longer Passed Through Chooser
The code startActivity(intent.createChooser(shareIntentWithJpgFileName))
had been working fine in my application for years, but I noticed about a month ago that it no longer passes the image file to the application that the user selects in the chooser dialog. I suspect Android OS security shuffling (again!), but not sure how to proceed.
If the user selects any number of choices in the chooser dialog, the application opens, but doesn't show the .jpg
that was part of the intent. If the user selects Google Drive, I get a hint of what's wrong through it's toast:
Upload unsuccessful: request contained no data
The Code that Used To Work:
String fileName = data.getStringExtra(EXTRA_FILENAME);
Log.v(TAG, "Starting Share intent. fileName: " + fileName); //This shows fileName: /storage/emulated/0/dcim/DalesApp/IMG_20190103_142555_8445288886207383328.jpg
Intent shareIntentWithJpgFileName = new Intent(Intent.ACTION_SEND);
shareIntentWithJpgFileName.setType("image/jpeg");
File filePassedIn = new File(fileName);
Log.v(TAG, "exists: " + filePassedIn.exists() + " canRead: " + filePassedIn.canRead()); // Result is exists: true canRead: true. Thanks Mark!
shareIntentWithJpgFileName.putExtra(MediaStore.EXTRA_OUTPUT, FileProvider.getUriForFile(this, BuildConfig.APPLICATION_ID + ".provider", filePassedIn));
shareIntentWithJpgFileName.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(Intent.createChooser(shareIntentWithJpgFileName, "Share Image"));
Also, I have this as part of the AndroidManifest.xml
:
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths"/>
</provider>
And this is also in the AndroidManifest.xml
:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Question
Why has this stopped working and how can I get it working again?
I would be pleased to maintain/update/fix/correct/delete this question, so please give me guidance if you find it unsatisfactory for any reason.
Addendum
I changed the filter in Logcat
from Show only selected application to No Filters and was able to see logging from all applications. There were probably 50 or so lines that popped-up. It's hard to tell which items are applicable to the intent I started, but some are obviously from the intent I started (selected Google Drive in the chooser dialog). I picked a few more interesting logging entries:
I/ActivityManager: START u0 {act=android.intent.action.SEND typ=image/jpeg flg=0xb080001 cmp=com.google.android.apps.docs/.shareitem.UploadMenuActivity (has extras)} from uid 10196
E/SchedPolicy: open of /dev/cpuctl/bg_non_interactive/tasks failed: No such file or directory
I/ActivityManager: Start proc 12705:com.google.android.apps.docs/u0a92 for activity com.google.android.apps.docs/.shareitem.UploadMenuActivity
E/AsyncTask #3-DataSourceHelper: Uploading single file but neither EXTRA_STREAM nor EXTRA_TEXT is specified.
E/main-UploadMenuActivity: No files requested to be uploaded: android.intent.action.SEND
I/LaunchCheckinHandler: Displayed com.google.android.apps.docs/.shareitem.UploadMenuActivity,cp,ca,570
My next step is checking into "EXTRA_STREAM", which I haven't done yet, but I might be close to solving this on my own.
android android-security android-intent-chooser
android android-security android-intent-chooser
edited Jan 3 at 20:19
Dale
asked Jan 3 at 19:48
DaleDale
1,68512546
1,68512546
1
I assume you've done some sanity checks onfilePassedIn
i.e.File::exists
,File::canRead
etc, just to rule this out upfront?
– Mark Keen
Jan 3 at 19:57
Thanks Mark. I added a debug line to the code. Both returned true.
– Dale
Jan 3 at 20:04
add a comment |
1
I assume you've done some sanity checks onfilePassedIn
i.e.File::exists
,File::canRead
etc, just to rule this out upfront?
– Mark Keen
Jan 3 at 19:57
Thanks Mark. I added a debug line to the code. Both returned true.
– Dale
Jan 3 at 20:04
1
1
I assume you've done some sanity checks on
filePassedIn
i.e. File::exists
, File::canRead
etc, just to rule this out upfront?– Mark Keen
Jan 3 at 19:57
I assume you've done some sanity checks on
filePassedIn
i.e. File::exists
, File::canRead
etc, just to rule this out upfront?– Mark Keen
Jan 3 at 19:57
Thanks Mark. I added a debug line to the code. Both returned true.
– Dale
Jan 3 at 20:04
Thanks Mark. I added a debug line to the code. Both returned true.
– Dale
Jan 3 at 20:04
add a comment |
1 Answer
1
active
oldest
votes
ACTION_SEND
uses Intent.EXTRA_STREAM
for binary content as per the documentation, not MediaStore.EXTRA_OUTPUT
.
I guess thatMediaStore.EXTRA_OUTPUT
quit getting supported.Intent.EXTRA_STREAM
works like a charm.
– Dale
Jan 3 at 20:27
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54028865%2fwhy-did-intent-createchoosershareintentwithjpgfilename-quit-working%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
ACTION_SEND
uses Intent.EXTRA_STREAM
for binary content as per the documentation, not MediaStore.EXTRA_OUTPUT
.
I guess thatMediaStore.EXTRA_OUTPUT
quit getting supported.Intent.EXTRA_STREAM
works like a charm.
– Dale
Jan 3 at 20:27
add a comment |
ACTION_SEND
uses Intent.EXTRA_STREAM
for binary content as per the documentation, not MediaStore.EXTRA_OUTPUT
.
I guess thatMediaStore.EXTRA_OUTPUT
quit getting supported.Intent.EXTRA_STREAM
works like a charm.
– Dale
Jan 3 at 20:27
add a comment |
ACTION_SEND
uses Intent.EXTRA_STREAM
for binary content as per the documentation, not MediaStore.EXTRA_OUTPUT
.
ACTION_SEND
uses Intent.EXTRA_STREAM
for binary content as per the documentation, not MediaStore.EXTRA_OUTPUT
.
answered Jan 3 at 20:15
ianhanniballakeianhanniballake
107k15221237
107k15221237
I guess thatMediaStore.EXTRA_OUTPUT
quit getting supported.Intent.EXTRA_STREAM
works like a charm.
– Dale
Jan 3 at 20:27
add a comment |
I guess thatMediaStore.EXTRA_OUTPUT
quit getting supported.Intent.EXTRA_STREAM
works like a charm.
– Dale
Jan 3 at 20:27
I guess that
MediaStore.EXTRA_OUTPUT
quit getting supported. Intent.EXTRA_STREAM
works like a charm.– Dale
Jan 3 at 20:27
I guess that
MediaStore.EXTRA_OUTPUT
quit getting supported. Intent.EXTRA_STREAM
works like a charm.– Dale
Jan 3 at 20:27
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54028865%2fwhy-did-intent-createchoosershareintentwithjpgfilename-quit-working%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
I assume you've done some sanity checks on
filePassedIn
i.e.File::exists
,File::canRead
etc, just to rule this out upfront?– Mark Keen
Jan 3 at 19:57
Thanks Mark. I added a debug line to the code. Both returned true.
– Dale
Jan 3 at 20:04