I am working so some demo app store. This app can detect deep link and install app from link. Before installing app user gets dialog (at least on Android 11 and 12) where he/she can click on Install or Cancel. Dialog is opened by PackageInstaller. I am using BroadcastReceiver to receive installation status (for example PackageInstaller.STATUS_PENDING_USER_ACTION). When user clicks on cancel or install or some error happens I receive a status.
But user can click outside of dialog. Dialog is smilingly dismissed and no status is reported back.
Is there way to get status? Or to make dialog non dismissible?
EDIT: dialog is create by PackageInstaller and I don’t have control it's properties.
Directly - no, but you can:
Track onResume event to detect when it's closed (it requires some filtering to avoid false detection);
Wrap it into some proxy activity and use startActivityForResult/onActivityResult to start that EXTRA_INTENT from STATUS_PENDING_USER_ACTION. resultCode is always 0, but you'll have an closing event at least.
Related
I'm looking to send a user to install an app from the Play Store, then once they click the install button I want to send them back to my app and show a progress bar and helpful info.
There is an app called Mistplay that does this. I know they detect the app installation, but I'm not sure if they are faking the app Install progress or not.
Any suggestions on this? I'm able to use intents to launch the play store market but I don't know how to detect the user clicking install in Play Store and sending the user back to my app or any of the steps past that.
Edit 1:
So I am able to detect when the installation finishes by including the target app in my Manifest Queries section + having this code (overly verbose for testing) in my main activity onCreate() + onDestroy unregister.
val filter = IntentFilter()
filter.addAction(Intent.ACTION_PACKAGE_ADDED)
filter.addAction(Intent.ACTION_PACKAGE_CHANGED)
filter.addAction(Intent.ACTION_PACKAGE_DATA_CLEARED)
filter.addAction(Intent.ACTION_PACKAGE_REMOVED)
filter.addAction(Intent.ACTION_PACKAGE_REPLACED)
filter.addAction(Intent.ACTION_PACKAGE_RESTARTED)
filter.addDataScheme("package")
registerReceiver(appInstallBroadcastReceiver, filter)
The scenario is as follows:
First, my app executes the example code for requesting user's approval to make the device Bluetooth-discoverable. This request opens up some kind of a system dialog, which asks the user "An app wants to make your phone visible to other Bluetooth devices for X seconds" and the user has to either accept or reject the request.
While that dialog is still showing (meaning that the user didn't interact with it yet), and in the meantime something else has happened in my app, then I want to be able to dismiss the dialog or cancel that request, on behalf of the user. Like "forget it, that's not relevant any more".
Is that possible in any way?
Events:
1.USB device plugged in.
Prompt appears saying: "Open appName when this USB device is connected?"
Press cancel -> app stays open | press okay -> app restarts
Required behaviour: The app either does not show the dialog and automatically opens the app when it's not in the foreground, or, when the app is in the foreground then when the user presses okay the app does not restart.
Attempted solution: I've tried making sure every Activity's launch mode is set to "SingleTask". This solution worked here but when I did the same thing the app still restarted.
Question in a nutshell: How do I stop my app restarting when the user says to open the app when the device is connected? Or, how do I stop this prompt entirely whilst still enabling my app to start when this USB device is connected?
I've seen similar questions which deal with stopping a prompt showing which asks whether the app should be allowed to access the connected device, but, my issue is dealing with a different prompt.
Thanks in advance.
the app uses an IntentFilter with an AppChooser or Launcher dialog https://developer.android.com/guide/components/intents-filters.html
this always happens when you use an IntentFilter on android.hardware.usb.action.USB_DEVICE_ATTACHED. Another possibility is that the dialog is an AppChooser or launcher dialog that is invoked when there are multiple apps (or multiple instances of the same / your app) that capture the USB attach event . This is why when you press Cancel the app stays open.
Using an intent filter
To have your application discover a particular USB device, you can
specify an intent filter to filter for the
android.hardware.usb.action.USB_DEVICE_ATTACHED intent. Along with
this intent filter, you need to specify a resource file that specifies
properties of the USB device, such as product and vendor ID. When
users connect a device that matches your device filter, the system
presents them with a dialog that asks if they want to start your
application. If users accept, your application automatically has
permission to access the device until the device is disconnected.
https://developer.android.com/guide/topics/connectivity/usb/host.html
this is a systems dialog that is internally linked to the android.hardware.usb.action.USB_DEVICE_ATTACHED event so disabling it will be difficult. there is the possibility to use <activity-alias>, https://developer.android.com/guide/topics/manifest/activity-alias-element.html you can route intents with it:
http://www.stackoverflow.com/questions/40182096/usb-permissions-without-prompt/40182413#40182413
http://blog.danlew.net/2014/01/16/preserve-your-launchers-use-activity-alias/
(Is there any way to have one and only one instance of each activity?)
I have an app here allowing the user to upload images. To pick the image I open the native browser with
var file:File = new File;
file.browse();
I encounter a strange problem when the user cancels the upload. In fact there are two ways this can be done:
a) the user clicks on the "back" button on the device or:
b) user clicks on an empty space on the (native) browse dialog window.
In the first case, AIR will fire an Event.CANCEL event and everything is fine.
In the second case no event will fire, still the browse dialog will quit, leaving my app in the state of still waiting for an upload. To deal with this, I added another button to my UI that will fire the event and call file.cancel(); file = null manually.
Unfortunately, this doesn't work as expected. When I try to open the browse dialog again, I get an Error Error #2041: Only one file browsing session may be performed at a time. The cancel is ignored.
Does anybody have an idea how to workaround this problem?
P.S. Tested on AIR 13 and Android 4.1 / Android 4.3
I have an android app, I want to run some process or show some message to user if he is uninstalling app, how to do that in android...
You could have a second app set up to receive a PACKAGE_REMOVED broadcast when the original app is removed. I don't think you can affect the first app being removed, but you at least you can react to it (to clean up files, etc.). That would only work, of course, if the second app was not removed first.
Not possible. If your user wants to uninstall your app, why do you think it would be OK to have anything pop up before they can do that?