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.
Related
I have an app that requires temporary access to the device's SMS. In KitKat and above, this access is only granted to the default SMS app, so I'm using:
Intent intent = new Intent(Telephony.Sms.Intents.ACTION_CHANGE_DEFAULT);
intent.putExtra(Telephony.Sms.Intents.EXTRA_PACKAGE_NAME, getPackageName());
startActivity(intent);
This brings up a dialog asking the user if they let my app become the default SMS app. So far so good. Problem is, once my app completes its operation, I have to ask the user again, if they want to restore their previous app as their default SMS app.
I'd like a way to avoid the second dialog, perhaps by having my app tell the Android OS that it no longer wishes to be the default SMS app, so that the previous app can automatically take over again. I know Android supports this, because if I uninstall my app while it is the default SMS app, Android will revert to the previous one automatically, with no need for user input. Any way to replicate this behaviour of ceding control without uninstalling?
To be eligible to be the default messaging app, your app has to have certain active components registered in the manifest. Disabling any one of them will make your app ineligible, and the system should automatically revert the default. We can use the PackageManager#setComponentEnabledSetting() method to disable a manifest-registered component.
For example, if the Receiver you have registered for the SMS_DELIVER action is named SmsReceiver:
getPackageManager()
.setComponentEnabledSetting(new ComponentName(this, SmsReceiver.class),
PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
PackageManager.DONT_KILL_APP);
Obviously, before your app could be set as the default again, you would need to re-enable that component, which you can do by calling the above method with PackageManager.COMPONENT_ENABLED_STATE_ENABLED as the second argument.
My team is developing an Android app that includes the ability to call and talk to customer support. We are calling an Intent with ACTION_DIAL, which brings up the dialer with the phone number pre-populated, as expected. In the device emulator, we also see links to Create a new Contact and Add to a Contact, which are fine, but we want to suppress the Send SMS link, since there is no way for us to read messages sent to that number. Ideally, I'd like to be able to pass a parameter or change a setting that disables SMS messaging for that one invocation, but I'm open to other solutions. Searches that I've done haven't turned up anything.
Thanks in advance,
Dan
No. There's no way of knowing what dialer is being launched for action dial- OEMs all have the option of using their own, or the user can even download one of their own. There's no way of knowing what options those dialers support, and definitely no way of configuring them. Even if there was, a dialer app could ignore the configuration. You may want to use ACTION_CALL instead, which requires additional permissions but will directly call without bringing up a prefilled dialer.
Background: I have an app which needs to use an intent from an other app. If this other app is not installed when its intent is needed, I would like to offer it for download and install.
Question: If the downloaded app is opened (by the user) immediately after installing it, I would need it to open the specific intent the first app needs instead of opening it as normal. See image below.
What options do I have available, is there a common pattern for this? Thanks in advance.
If the downloaded app is opened (by the user) immediately after installing it, I would need it to open the specific intent the first app needs instead of opening it as normal.
That is not possible, strictly speaking. There is nothing stopping the user from pressing Open, and that will behave as normal -- you cannot change this.
If you are the author of the, um, "Monkey Trampoline" app, you could work out various hacks to recognize that it is being opened after an install from, um, "Animal Olympics", so it can route its logic accordingly (use a custom sticky broadcast, have the second app use some IPC to ask the first app "yo, am I supposed to do something special?", etc.).
It is also conceivable that ACTION_PACKAGE_ADDED will be broadcast before the user clicks either Done or Open (or HOME or BACK or whatever). In that case, you could listen for that broadcast, determine that, indeed, the app just installed does involve simian somersaults, and call startActivity(). This will be a bit jarring for the user, insofar as all of a sudden they'd be transported from the install process into this new app. And, since the precise timing of ACTION_PACKAGE_ADDED is undocumented, your mileage may vary (e.g., the user could still get a chance to tap Open before the broadcast winds its way to your app).
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.
is it possible to press a button and start a call e.x. in skype?(i know that is possible for a telephone call but i would like to see if i can make this stuff with a voip app as skype)
If the user has skype installed, and the user tries to place a call there are two options you can take:
i.e. just try and call skype directly (but this requires knowing the correct intent to launch skype) or you request to make a call and the user will be shown the option to use skype to place the call (unless they've set the default dialer and the primary application).
I think there may be a way to get a list of activities that are registered to handle certain events (i.e. get the list of dialler apps on the device) from this you might be able to find the skype app and get enough information to force the use of that. The problem with this is you are then tied into using skype and only skype rather than let the platform handle it.