ACTION_IMAGE_CAPTURE | Can't get past SAVE/DELETE menu - java

First of, this is not a duplicate, I've seen similar posts but with no good answers. Now, this is the menu I'm talking about:
This only happens in some devices, in my particular Samsung Galaxy S3 Neo, it does well, and everything that it's supposed to, but on a friend of mines Wiko (French brand, but pretty good), aswell as on the emulator above, it just does nothing when I click on "save". Here is my code if you could take a look:
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
imageFile = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), path);
Uri tempuri = Uri.fromFile(imageFile);
intent.putExtra(MediaStore.EXTRA_OUTPUT, tempuri);
intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
startActivityForResult(intent, 0);
If you need any more details tell me :)

Related

How to clear other apps cache programmatically in android 11?

I search a lot but can't found any solution. https://developer.android.com/reference/android/os/storage/StorageManager#ACTION_CLEAR_APP_CACHE I tried with two codes but not working.
this is first one:
Intent intent = new Intent();
intent.setAction(ACTION_CLEAR_APP_CACHE);
startActivityForResult(intent,REQUEST_CLEAR_APP_CACHE);
And this is second one:
Intent storageIntent = new Intent();
storageIntent.setAction(ACTION_MANAGE_STORAGE);
startActivity(storageIntent);
this is just open only download folder to free some space.
if anyone have solution please post. Thanks in advance.

Android open external IMDB application from my app

I have a button in my application which opens the imdb application in the phone with a imdb id I received from https://developers.themoviedb.org/3/getting-started/introduction
But I couldnt find anyway(using intents) to make my app recognize the imdb app and open it and if imdb app do not exist then I want to open the web site. How can I accomplish this?
I think I may be able to point you in the right direction. Just to be sure, you seem to be using TMDB but wish to open in the IMDB app?
The code below is from the Android documentation.
It will start your intent if the package manager can find an app with the appropriate intent filter installed on your device. If multiple apps are able to open this intent then an app chooser should pop up, unless the user has previously set a default for this kind of URI.
Intent sendIntent = new Intent(Intent.ACTION_SEND);
// Always use string resources for UI text.
// This says something like "Share this photo with"
String title = getResources().getString(R.string.chooser_title);
// Create intent to show the chooser dialog
Intent chooser = Intent.createChooser(sendIntent, title);
// Verify the original intent will resolve to at least one activity
if (sendIntent.resolveActivity(getPackageManager()) != null) {
startActivity(chooser);
}
If you add an else onto that then you can use a view intent like this :
Intent internetIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(movieUrl));
//Watch out here , There is a URI and Uri class!!!!
if (internetIntent.resolveActivity(getPackageManager()) != null){
startActivity(internetIntent);
}
I also found this (rather old) post about calling an explicit imdb uri
Imdb description
startActivity(android.intent.action.VIEW, imdb:///title/<titleID>);
// take note of the Uri scheme "imdb"
I hope this helps. If you post some more detail , code, links , I might be able to work through this with you.
If my answer is way off base then please be kind and set me right. We are all learning every day!
Good Luck.

Android Sharing Intent only works with Google Photos, Crashes Other Apps [duplicate]

This question already has answers here:
Android ACTION_SEND event: "messaging failed to upload attachment"
(2 answers)
Closed 5 years ago.
I am trying to create a Sharing Intent for an Android App to share images to other apps. However, I'm getting this really weird result when implementing this feature.
I have a share button that when I click on the button, it runs the following method:
private void shareIntent() {
Uri currUri = Uri.parse(data.get(pos).getUrl());
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
sharingIntent.setAction(Intent.ACTION_SEND);
sharingIntent.putExtra(Intent.EXTRA_STREAM, currUri);
sharingIntent.setType("image/jpg");
startActivity(Intent.createChooser(sharingIntent, getResources().getText(R.string.share_to)));
}
data.get(pos).getUrl() returns the URL of a custom class I made that implements Parcelable, and when printing it out, it returns a directory like the following: "/storage/emulated/0/Pictures/primitive/Primitive-79538313.jpg"
The intent works at first, opening the sharing menu. However, when I click on most applications, it either crashes the application or it gives an error... except with Google Photos, which uploads the photo properly to the gallery.
Firstly, I'm wondering what I'm doing wrong to cause this issue in the other apps. Also, I'd like to know if someone has an explanation as to why only Google Photos allows the sharing feature to work, while many of the other apps I've tested do not.
For reference, here are some examples I've run with the sharing intent. When I try to share the image, it crashes Hangouts. It gives a "failed to load image" error message in Snapchat, "Unable to share file" in Slack and Gmail, "Upload was unsuccessful" in Drive, "Messenger was unable to process the file" in, well, Messenger, and "Couldn't load image" in GroupMe. It doesn't load the image in Facebook but doesn't crash nor give an error.
Thank you for any help or feedback you can provide!
EDIT:
This seemed to work without trying to get around App Permissions:
private void shareIntent() {
File imageFile = new File(data.get(pos).getUrl());
Uri uriToImage = FileProvider.getUriForFile(
this, BuildConfig.APPLICATION_ID + ".provider", imageFile);
Intent shareIntent = ShareCompat.IntentBuilder.from(DetailActivity.this)
.setStream(uriToImage)
.getIntent();
shareIntent.setData(uriToImage);
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
shareIntent.setType("image/jpeg");
startActivity(Intent.createChooser(shareIntent, "Share image"));
}
Thank you to everyone that responded!
Change your code to this
private void shareIntent() {
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("image/jepg");
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://"+data.get(pos).getUrl()));
startActivity(Intent.createChooser(shareIntent, "Share image"));
}
Add this code in your activity onCreate()
StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();
StrictMode.setVmPolicy(builder.build());

Front facing camera takes upside down pictures

So, I am developing a small game for my final school project, and I am having this problem, whenever I take a picture with the front facing camera, it saves it upside down, when I use the good old back camera however, it's all fine and it takes the photo properly. Here's the code that I'm using to take the picture:
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
imageFile = new File(
Environment
.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "goQuiz/profilePic.jpg"
);
Uri tempuri = Uri.fromFile(imageFile);
intent.putExtra(MediaStore.EXTRA_OUTPUT, tempuri);
intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
startActivityForResult(intent, 0);
I used this video to help me get the code done: Video.
Any help will be greatly apreciated, thanks.

Check if intent can be handle. Didnt work for zxing intent

i am trying to check if there is any activity, which can handle my intent: "com.google.zxing.client.android". Main application, which can handle this is BarCode Scanner from ZXing company, but QR Droid can do i too.
I am using this:
List<ResolveInfo> list = packageManager.queryIntentActivities(intent,
PackageManager.MATCH_DEFAULT_ONLY);
if (list.size() == 0) //no activity can handle that
and this:
Intent test = new Intent(Intent.ACTION_VIEW,
Uri.parse("com.google.zxing.client.android"));
if (context.getPackageManager().resolveActivity(test, 0) == null)
//no activity can handy that
Main problem is, if i have only QR Droid installed and BarCode Scanner dont. Result of this two conditions is true (there isnt any application, which can handle that). But if i run that intent:
Intent intentScan = new Intent("com.google.zxing.client.android.SCAN");
fragment.startActivityForResult(intentScan, RequestCodes.REQUEST_CODE_SCAN);
QR Droid application is started. Which is good, but i cant predict that :(
Thanks for answers :)
You're not showing intent in the first snippet, which should work since it is how it is supposed to be queried: https://code.google.com/p/zxing/source/browse/trunk/android-integration/src/com/google/zxing/integration/android/IntentIntegrator.java#288
I bet you have set a package on intent which restricts it.
Check the intent you are going to launch.
(PS ZXing is not a company)

Categories