Android - 'Complete action using' keeps showing even after selecting 'Always' - java

I'm trying to use an intent to browse for images. I managed to get my code working but the only problem is that every time I choose the browse file button, the app always shows the pop up dialog 'Complete action using' even after Always is selected.
I still want the user to select from the available app installed and set it as default when 'always' is selected.
Do I need to programmatically save the user's choice? I have only tested this in Genymotion's emulator (Android's Studios emulator is very slow in my laptop) and my Lenovo S820 Android 4.4.2. Is it a specific bug in my phone or am I missing something? Thank you in advance.
I have searched everywhere and found this similar
question, but it's also unanswered.
I am calling my intent like this:
public Intent browse(){
Intent getterIntent = new Intent(Intent.ACTION_GET_CONTENT);
getterIntent.addCategory(Intent.CATEGORY_OPENABLE);
getterIntent.setType("image/*");
return getterIntent;
}

Related

Uninstall an Android app programmatically without prompt interaction?

I'm developing an Android app.
I used the following code to uninstall a specific application.
Intent intent = new Intent(Intent.ACTION_DELETE); intent.setData(Uri.parse("package:com.example.tharindurasanga.locationtracker"));
startActivity(intent);
This code really works fine but not giving what I'm expecting since this is resulting a prompt saying user to confirm the app uninstallation. I need to uninstall the app silently without user confirmation.
Can someone suggest me another method of doing this or help me to remove this prompt?

Android Settings permissions not not acting as they should

I need to ask for permission from the user. One of the permissions I need is ACTION_MANAGE_OVERLAY_PERMISSION and the other is Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION. When asking for it as you can see in the code below, it takes the user to the Settings screen so the user could tick the permission from there.
Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
Uri.parse("package:" + getPackageName()));
startActivityForResult(intent, OVERLAY_PERMISSION_REQUEST_CODE);
On some Android phones and Android versions, it takes the user straight to the specific application setting (the app that it is called from) on other devices it opens up the list of applications from which the user has to find the app and then tick the permission. In most cases on Androids lower than 10 it opens up the specific app settings window and when it's 10 or higher, it opens up the list.
Is there a way to make it consistently open the current application setting that is open?
I tried adding:
intent.addCategory("android.intent.category.DEFAULT");
intent.setData(Uri.parse("package:" + getApplicationContext().getPackageName()));
But that did not help either.
And secondly, is there a way to ask for this and other Settings permissions without opening the Settings menu and instead of doing it in a dialog inside the application?
If not then is there a way to ask for multiple Settings permissions one after another because my application requires two Settings type permissions.
EDIT
Here is what I meant by the specific application settings vs the list.
On the left picture, all apps are listed and on the right picture the specific app is opened (happens if you click on the app in the list).
Now in some cases, it directly opens the right picture but mostly it opens the left. Is there a way to force open the right picture at all times?
Is there a way to force open the right picture at all times?
No.
The Settings app usually is modified substantially by the device manufacturer. They can do whatever they want. This includes ignoring the Uri or outright removing third-party access to this screen, where the latter is what the documentation is warning against:
In some cases, a matching Activity may not exist, so ensure you safeguard against this.
If you make your own Android firmware, you could ensure that this Intent action behaves as you want, for whatever devices run your firmware.

Is there a way to detect when a popup window appears in Android

I started a project of a windows program that connects to an android phone and gives the user information
about it, so I want to display all of the popups that appere on the phone. to do this I need the app version of the program to catch them somehow and give me the name of the app that sent the popup and the popup's contant. is it possible?
it would be kind of security issue if any app could do that... you can try with AccessibilityService with some permissions for reading screen/running Activities and checking style of every Activity is this "popup", but note that some of them are just DialogFragments. So I doubt you can recognize "popups" this way in a reliable way. Look for AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED for more info

Android Intent choose set default app

I am working on an android app and when a user clicks on a link and/or file, I want to give them the choice of choosing which app they want to use to open that link and/or file. At the moment it works the way it was intended to, but I am having trouble trying to let the user select a checkbox which lets them choose the default app to open that file with so they won't have to keep selecting it each time. I was thinking of having a checkbox in the dialog and then committing the value of it to the Shared prefs along with the app choice. After that, each time they click that file, the default app will be opened. In essence I am trying to get a dialog like this one,
But I keep getting this one,
Here is the code:
Intent intent = new Intent(Intent.ACTION_VIEW).setDataAndType(uri, mimeChoice);
startActivity(Intent.createChooser(intent,getActivity().getString(R.string.open_with_title)));
like tambykojak point out, the "The Android OS will take care of this depending on the Intent you've constructed" and thereĀ“s no option for default app. But you will construct your own custom dialog by gettin the apps installed determined by the package:
for example:
Facebook: "com.facebook.katana"; Whatsapp: "com.whatsapp"; Twitter: "com.twitter.android"; Google Playstore: "com.android.vending"; Chrome: "com.android.chrome" etc...
And saving the "default" option in preferences.
More info:
How to force Share Intent to open a specific app?
How to filter specific apps for ACTION_SEND intent (and set a different text for each app)

Settings activity

I am making an new android app and I would like to make a settings activity where the use can see about info and settings.
So on android devices you have buttons for settings or else it is presented on screen, when I click that button I do get a menu with the name settings (which I guess eclipse once made automatically) and I do have a activity_settings (as a launcher activity, I don't know if that has any influence or what it means actually) but how can I link the menu tab and the activity?
I mean that when in the menu is clicked on the settings-tab the activity opens.
Can you help me out?
Thanks in advance,
Ide
Yes, what Samarth is saying is true. Read the developer guide before you post questions here. A simple google search will give you links as well.
Here's a complete explanation on how to implement Menus and how to do it: http://developer.android.com/guide/topics/ui/menus.html
Also a similar question on how to create an option Menu: Android, How to create option Menu

Categories