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
Related
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.
I want to create an android app which does one thing (change a setting and save that it did that) and then stops (exits? Stops ? gets destroyed?) before a form is loaded or shown.
Then when I run the app again, I read wether the app has chaged the setting, and then undo's that and then stops (exits? Stops ? gets destroyed?) before a form is loaded or shown.
You can compare it with an existing flashlight app: you click the icon and the flaslight (led) goes on (and no form is shown) and when you click the icon again, the flaslight (led) goes off.
Sounds easy, but I'm not sure I how to do this. Looking at the activity flow (http://developer.android.com/reference/android/app/Activity.html) didn't really help....
I have developed an app in Cordova 3.6 with latest version of InAppBrowser. Run on Android device (4.1.2 and others) when the user taps a link to open InAppBrowser, occasionally a double window seems to open up. The second of these windows doesn't close.
To check if it was something I had done in my app, I quickly created a default Cordova hello world app and added the standard window.open code with link like this
OPEN WINDOW
and basic testing on the device revealed the same thing was happening - occasionally fast or double tapping made a double window open up, one of which was uncloseable. Either from <300ms double tap, or from double taps where the browser is slow to launch.
This doesn't appear to happen on iOS.
Any help gratefully appreciated.
UPDATE
Part of the problem on my main app was functions declared in wrong place (onpagecreate) being fired multiple times. I put this here in case someone does anything similar...
However on the hello world app the problem still occasionally happens. I tried with and without Fastclick, but Fastclick didn't work properly (possible conflict with jQuery Mobile, arrghh).
your problem is likely caused by using the 'onclick' event to launch the childbrowser.
onclick has a built in 300ms timeout, which can make an app appear laggy and causes some of the issues above.
Use mouseup/mousedown instead, and inside the handler, disable the listener
OPEN WINDOW
function open(url, name) {
// deregister the onclick listener, insuring the callback resolves
window.open(url,name);
// register the listener
}
I am trying to integrate with the LinkedIn api within my app. Most of it is working just fine but for 1 issue. This is how it works:
From my apps settings screen, the user clicks on connect to LinkedIn button which brings up the web view where the user has to enter their linkedin credentials. The web view is launched the following way:
Intent i = new Intent(Intent.ACTION_VIEW,Uri.parse(liToken.getAuthorizationUrl()));
i.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
startActivity(i);
The above is actually done via an asynctask class.
After successful auth from linkedin, the web view goes away and the user comes back to my apps settings page. Here the user has 2 options. He can either click on save or can hit the cancel button. Save button saves the settings and then takes them to the main activity, cancel doesn't save anything and then takes them to the main activity.
The problem is, this all works just fine on 4.2.2 emulator, but on a Google LG Nexus4 device running 4.2.2, hitting on either the save or the cancel button brings back the linkedin webview, which is not the desired behavior.
One thing that I wanted to point out was that the emulator uses the default android browser while nexus4 uses chrome? is that the problem here?
Do I need to set some other flag on the intent?
Have you tried cleaning your project and rebuilding? Delete the app from the device and reinstall?
Suppose I want to start an app to run in background as soon as an event occurs in the phone.
For example:-
When I open my gallery I may want to automatically start my app which monitors my file browsing and prepares database for most recent documents, most listened song, etc and is automatically closed when I exit my gallery folder.
Whenever I open my internet browser I might want to start my app in background, which monitors how many times I visited a particular site and it automatically closes when I close the browser.
I don't think this is possible, and i'm not talking about remote launch app, but capture events of other apps like Gallery or Browser.
If this are only hipotetic examples, you should show a real examples because i think collect this type of data will be more painful problem than trigger app on an event due a lot of security reasons.