Need for Intent.createChooser method when using implicit Intent - android

I don't understand why one needs to use Intent.createChooser when using implicit intent. According to Android docs "If multiple intent filters are compatible, the system displays a dialog so the user can pick which app to use". So if the android system pops up a chooser dialog why to use createChooser method?
Thank u in advance

yes, android system will do this for you. But once you choose an item from the dialog, the system will keep it in mind and it will NOT show the dialog next time if the user chooses a "default". this isn't always what you want. Suppose you have a share button, you certainly don't want your users to share with a same approach all the time. So it's the case where you'll need a createChooser call. This forces the system to show the choosing dialog each time.
you can refer to this

Related

Android: take camera picture intent remove confirmation dialog

it's possible to disable/remove this photo confirmation dialog:
I need somehow skip this dialog but I still want use an Intent. I found this android: Take camera picture without "save" / "delete" confirmation but I don't want use SurfaceView .
I need somehow skip this dialog but I still want use an Intent.
That is not possible.
There are over 8,000 26,000 Android device models. Across them, there are hundreds of different pre-installed camera apps. Additionally, there are hundreds of additional camera apps that users can install from the Play Store or elsewhere. Any one of them could respond to your ACTION_IMAGE_CAPTURE request.
The protocol for ACTION_IMAGE_CAPTURE does not have an option for "do not show any sort of confirmation dialog". Some camera apps will have such a dialog, others will not. A few apps might have some undocumented Intent extra for controlling that behavior, but most will not.
Either:
Live with the confirmation prompt, where it exists, or
Do not delegate this work to a third-party app, but instead use the camera APIs to take a picture yourself (the SurfaceView approach that you rejected, though it does not necessarily need SurfaceView), or
Do not write the app
Use "android.intent.extra.quickCapture" in Intent.
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra("android.intent.extra.quickCapture",true);

android bypass app chooser

I understand that Android does not allow you to call an emergency number (911) directly. So I have decided to use Intent.ACTION_DIAL instead to leave the app and have the number pre-dialed, ready to call. However, the app chooser appears when I hit my 'Dial 911' button, adding another unnecessary step to the process (the other option besides the Phone app is to scan the number using Lookout Security).
Is there anyway to bypass the app chooser by pre-defining the app to handle the Intent?
There are many possible dialers. You have no good way of determining a priori which is the "one true dialer" that the user wants to use. Moreover, the user should be able to click "Always" on the chooser and therefore only encounter this once.
If you want, you could allow the user to choose their dialer up front, perhaps as part of configuring your app. You can use PackageManager and queryIntentActivities() to find out what all supports ACTION_DIAL, presenting that to the user to choose from. You would remember the ComponentName of their choice, and add that ComponentName to the ACTION_DIAL Intent that you use "for realz" when the user presses the button in your app.

How does intent filter work in android

In android if there are more than two apps which can receive same intent then a dialogue will pop up to ask user to select which app to do the action
for ex : when user click on any link it will pop up the below dialogue
So my question is which app will perform this display of dialogue for asking the user.
It will be appreciated if some one explains how does it work.
Many thanks.
this dialog is open by operating system. it check the manifest of other apps and search in intent filter for action that is invoked and those that full fill the need of action shows in the dialog.
basically intent filter specify : which activity can respond to which event or action. If it say action_view then all those activities will open that can respond to view intent filter.
lets see.
here app 1 say i want action param_c. so os search in manifest of other application for action param_c and all those app that can respond to param_c will showed in dialog and now it will upto user which activity it want to respond.
* if there is only one activity that can respond to it then it will directly opened.no dialog will be showed.
So my question is which app will perform this display of dialogue for
asking the user.
Answer : System, based on the manifest files of all the applications. And the dialog your are talking is chooser dialog.
Explanation :
When startActivity() is called ,the system examines all of the installed apps to determine which ones can handle that specific kind of intent. If there's only one app that can handle it, that app opens immediately and is given the intent. If multiple activities accept the intent, the system displays a dialog so the user can pick which app to use.
However, if multiple apps can respond to the intent and the user might want to use a different app each time, it is better to show a chooser dialog. The chooser dialog asks the user to select which app to use for the action every time (the user cannot select a default app for the action).
For example, when your app performs "share" with the ACTION_SEND action, users may want to share using a different app depending on their current situation, so you should always use the chooser dialog.
To show the chooser, create an Intent using createChooser() and pass it to startActivity(). For example:
// Create intent to show chooser
Intent chooser = Intent.createChooser(intent, title);
This displays a dialog with a list of apps that respond to the intent passed to the createChooser() method and uses the supplied text as the dialog title.
For more information refer Intent-Filters

How to set Default action in Android from coding?

Once my Home Screen app 'ABC' is installed on the device & when the user presses the Home Button, he is prompted with the Default Action Android dialog to choose between the Default Home & my ABC app.
My use case is to keep on prompting the user - a bit infrequently though, with this Default Action dialog till he selects my App as default.
How we can default action in android ?
Before ICS (and maybe Honeycomb), you could set the preferred activity using the PackageManager#addPreferredActivity method.
But as stated in the documentation :
This is a protected API that should not have been available to third party applications. It is the platform's responsibility for assigning preferred activities and this can not be directly modified.
This indeed could be used by Malware to change what applications the launcher icons start. I would really advise you not to use it and instead let your users the choice to make themselves your launcher their default launcher.
call the below intent when you need to see the 'launcher' selection dialog, unless one of the launcher apps is set as default
Intent homeIntent = new Intent("android.intent.action.MAIN");
homeIntent.addCategory("android.intent.category.HOME");
startActivity(homeIntent);

android custom intent chooser

We have an app that starts an activity for SENDTO with the intention of letting the user send an email. the choice of all the various email apps is fine, but we'd like to give the user of bypassing that step in the future ... e.g., add a "remember this decision" button at the bottom of the chooser. from then on, we'd launch that specific activity instead of getting the chooser.
I'm wondering if we can interact with the built-in create chooser functionality at a lower level to affect this. If not, could someone point / post some code snippets for this? I suppose the trick is understanding how to get a list of activities that can handle the intent.
I've seen a lot of questions about modifying the app chooser, and they all seem to state that no, you cannot change the built-in app chooser, but you can create a custom app chooser using queryIntentActivities() in the PackageManager class.

Categories

Resources