Flex 4.6 Mobile- soft keyboard and andorid back button

Forgive me as I posted this question in another thread but it doesn't seem to be getting much attention.
When using Flex 4.6 on Android I've noticed an undesired behavior related to the soft keyboard.
When the soft keyboard is open and you press the hardware back button two things happen:
First, the keyboard closes.
Then, if you're on a secondary view you get a pop view or if you're on the home view the app closes.
I've been trying to solve this by overriding the hardware back button but have yet to come up with anything that works. It seems most of the posted solutions are for older versions of Flex and don't seem to work in 4.6
Both of my phones I'm testing this on are HTC's incase this is hardware specific.

Hi GEG_man and frank,
try to do as shown in the code below works for me, I tried to simplify the code to SoftKeyboard to prevent the application exits on pressing the back button:
<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
        xmlns:s="library://ns.adobe.com/flex/spark"
        title="Test SoftKeyBoard" viewActivate="view1_viewActivateHandler(event)" backKeyPressed="backKeyPressedHandler(event)"
        destructionPolicy="never">
    <fx:Script>
        <![CDATA[
            import mx.events.FlexEvent;
            import spark.events.IndexChangeEvent;
            import spark.events.TextOperationEvent;
            import spark.events.ViewNavigatorEvent;
            private var focusInOut:Boolean = false;
            protected function view1_viewActivateHandler(event:ViewNavigatorEvent):void
                message.text = data.description;
                message.setFocus();
            protected function backKeyPressedHandler( event:FlexEvent ):void {
                //trace("Trigger: "+event.type);
                //trace("USER_TRIGGERED: "+SoftKeyboardTrigger.USER_TRIGGERED.length);
                if(SoftKeyboardTrigger.USER_TRIGGERED.length == 13 && focusInOut==true){
                    event.preventDefault();
                    stage.focus = stage;
                } else {
                     stage.focus = null;
            protected function recipient_softKeyboardActivateHandler(event:SoftKeyboardEvent):void
                trace("Activate: "+event.type);
                event.preventDefault();
                stage.focus = null;
                setFocus()==true;               
            protected function recipient_softKeyboardDeactivateHandler(event:SoftKeyboardEvent):void
                //trace("Deactivate: "+event.type);
                event.preventDefault();
                stage.focus = stage;
                setFocus()==false;
        ]]>
    </fx:Script>
    <s:TextArea id="message" width="100%" height="300" change="message_changeHandler(event)" text="{data.description}"
                softKeyboardActivate="recipient_softKeyboardActivateHandler(event)" softKeyboardDeactivate="recipient_softKeyboardDeactivateHandler(event)"
                focusIn="focusInOut=true" focusOut="focusInOut=false"/>
</s:View>
I've tested it on Galaxy S3 and LG P990 and Air 3.4/3,5/3.6.
enjoy
Franco

Similar Messages

  • Keyboard and andorid back button

    I've discovered one bad issue in app with multiple views.
    Way to reproduce:
    1) Activate keyboard at the second view in textInput.
    2) Press back. (Keyboard will disapper.)
    3) Press back. App will exit, but it' will not return to the previous view, as it should be.
    I've tested it on Galaxy Nexus and Xperia Ray and Air 3.1/3,2.
    Here is likely the same problem. Sample fxp: http://francisaltomare.com/_etc/TestBackKey.fxp

    May be you are right. I've briefly reviewed flex source and I can't say if it is a flex problem or the problem in air and flex interaction, but in pure AS project there is no such issue. But this issue happens in simple flex mobile project.
    This code works great in pure AS3:
    stage.addEventListener(KeyboardEvent.KEY_DOWN,keyboardHandler,false);
    protected function keyboardHandler(event:KeyboardEvent):void
         if (event.keyCode == Keyboard.BACK)
          event.preventDefault();
    In Flex project based on Application it does not work at all. I've tried to set listener to stage, systemManager.stage and "this" in Application. In Flex sources I can find logic dependent from Keyboard.BACK only in ViewNavigatorApplicationBase.

  • I open a new webpage in a new tab. I then go to a link and the back button does not allow me to go back to the original webpage. Any suggestions?

    I open a new webpage in a new tab. I then go to a link and the back button does not allow me to go back to the original webpage. Any suggestions?

    I don't think you understood the question. I am having the exact same issue. I open a link in a new tab or window, for example: https://addons.mozilla.org/firefox/addon/backforedrop/
    When the new tab opens, I click on "reviews" to open the link: https://addons.mozilla.org/en-US/firefox/addon/backforedrop/#reviews in the existing tab because I want to see the reviews for this feature. After I read the reviews, I want to go back to the main link, but the back button on my browser is greyed out, as though I was never even on the previous page. So my options are 1) Open every link I ever click on in a new tab or window, or 2) Hope the website is user friendly and attempt to navigate back to the previous page using links inserted on the current page.
    You never realize how frustrating not having back button is until it happens.

  • How do i have status bar and a back button  for applets?

    I have an applet which displays a set of panels in order. Is there any way that i can have a status bar like in an browser and a back button so that it can go back and go forward. What do i need to do? Is there any sample code to do so. I am new to java and learning.
    Thanks
    Ram

    Status-Bar -- a long thin panel with a long TextField. Perhaps use something from the BorderFactory class to seperate it from other parts of the screen...
    Back Button -- Keep track of your panels in a CardLayout, for example, then use a Button with an action listener that uses the CardLayout's previous() method to move back to the last panel.

  • I bought iphone 5c 4-5 days back from india and today back button of this phone not working, i am totally dissatisfy with the apple service support. i want replacement

    (i bought iphone 5c 4-5 days back from india and today back button of this phone not working, i am totally dissatisfy with the apple service support. i want replacement.)
    Hello i am nitin from india, i purchased a iphone5c because i heard that iphone comes with a great coustmer service, but this statment becomes totally wrong today, when i faced coustmer executive at service center of iphone then he said that i have to check it out and it may be a physical damage, ( how it is possible even i carried this phone with anti shock cover guard and its never fall down from my hand.) the simple thing i know that i want my phone replaced, otherwise it would be a great mistake of my life to purchase an iphone.
                                                                                          Thanks to all apple team for your wonderful service,

    Welcome to the user to User Technical Support Forum provided by Apple.
    For your issue... See here...
    Contacting Apple World Wide for Support and Service
    http://support.apple.com/kb/HE57
    Apple Warranty  >  http://www.apple.com/legal/warranty/
    iPhone Warranty  >  The warranty is only valid in the country of original purchase... Except for EU Countries...

  • I updated Firefox on my Mac (10.6.8), and now history is not remembered (that option is checked) and the back button won't work. Help?

    I updated Firefox on my Mac (10.6.8), and now history is not remembered (that option is checked) and the back button won't work. Help?

    A possible cause is a problem with the file places.sqlite that stores the bookmarks and the history.
    *http://kb.mozillazine.org/Bookmarks_history_and_toolbar_buttons_not_working_-_Firefox
    *https://support.mozilla.org/kb/Bookmarks+not+saved#w_fix-the-bookmarks-file
    You can also try to repair the places database with this extension:
    *https://addons.mozilla.org/firefox/addon/places-maintenance/

  • My keyboard and my external buttons no longer work.

    I guess it's probably a hardware problem and I'll have them repaired, but I am informed anyway.
    Last night, suddenly my keyboard, trackpad and all my external buttons no longer work. Only my touch screen works, but no back button, a BlackBerry is not very useful.
    It may be software, but I updated yesterday the operating system. But I find it strange that all the external buttons do not work together.
    What could be the problem. If I have to go to the workshop, I want to know as much as possible.
    Thanks !
    BlackBerry 9800

    Evolution, keyboard work again, but screen close often (lock button), probably humidity 

  • W520 keyboard and trackpad right button

    Now finally my 16 GB ram came and I had to open up the keyboard. The only problem was along with the keyboard came out the left Ctrl key and the right button for the track pad. Now the the right button would not go in and what more there are two small locks on top of it and one of the small plastic has fallen off . Is there a way to replace it ? I eventually manage to place the button with one lock but I think it's loose and might come off. 
    Also I'm unable to put back the Ctrl key. I put the ky on top and press it evenly, it should do it for other laptop. How do you put they key back on keyboard for W520 ? 

    palhello wrote:
     ..will the warranty cover keyboard replacement ? 
    Yes, if it is due to a manufacturing defect or a failure of a component within the keyboard.  I have replaced keyboards in the past, typically around the 2 year mark (I wear them out).  Lenovo has always been very courteous about shipping me a new keyboard (free) - just give them a call.  It is an easy to install part.
    Michael
    W520 (4270 CTO), which replaced a W500 (4062-27U), which replaced a T42P, which replaced an A21P...

  • Keyboard and website address buttons?

    Why when you hold the ".com" button do you get .us, .net .edu .org but no .ca? I use the Canadian keyboard and the thing was bought in Canada. Shouldn't there be a .ca since it is the country's official web url ending?

    Yup. If you pick the French Canadian keyboard you can get the .ca ending.
    C'mon Apple, most of Canada speaks English!

  • Upgraded to FF 17 for Mac, can't navigate backwards via back button, keyboard shortcut, or back button's drop-down.

    Back button, back-button's dropdown menu, keyboard shortcut (command-[) don't function after upgrade. I've disabled extensions that seem suspect.

    Did you try to disable all extensions?
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes
    You can also check for problems with the places.sqlite database file in the Firefox Profile Folder.
    *http://kb.mozillazine.org/Bookmarks_history_and_toolbar_buttons_not_working_-_Firefox
    *https://support.mozilla.org/kb/Bookmarks+not+saved#w_fix-the-bookmarks-file

  • Insert forms and the back button

    Hi,
    I have a page that is transparent to the user and does a
    standard DW insert
    using ASP. It uses <body
    onLoad="document.form1.submit()"> to do this.
    The user clicks on a link, this page does the insert, and
    then they are
    redirected to a results page.
    The problem is if they click on the back button from the
    results page the
    insert happens again and they end up on the results page
    again.
    If they click on the back button I want them to go back to
    the first page
    with the link (and obviously not do the insert).
    How can I do this?
    tia
    -Joe

    Jo,
    How about putting in a <<back link yourself for the
    user to click that takes them to the page you want.
    Paul

  • PPR and the Back Button

    Hi all,
    I posted recently about a workaround Oracle showed me for helping manage back button problems more efficiently, but now I'm having a separate back button problem.
    Changes that were made to a page via PPR disappear after coming back to the page by clicking the browser back button--for example, if I added a row to an <af:table> using PPR, navigate off the page, and click the back button, the row will disappear again--although it will reappear as soon as any event re-refreshes the table. I've tried turning off browser chaching, and it makes no difference, which makes me suspect this is not a browser caching issue.
    Does anyone know if there's a way to make sure a component is always refreshed when the page is loaded, even if it was loaded via the browser back button?
    Thanks much,
    Avrom

    Hi Frank,
    Great idea, thanks! I haven't tried it out in all my cases, but it looks like it's going to work!
    For the use of others, here's what you do:
    1) Make sure your model layer is capable of supporting the back button here, of course.
    2) Create a method, String refresh(), in a backing bean. This method can be a no-op (just return null) if you don't need to do any work to re-set the page. But if, for example, you calculated values referred to in the page, you should re-calculate them here. If you had code that calculated them when the page was originally loaded (*not* for PPR), you can take that out, because this will always get called on a new load/back button load/reload.
    3) Add a CommandLink like this one to your page (needs to be in a form, but otherwise it doesn't really matter where):
    <af:commandLink id="refresh" partialSubmit="true"
      action="#{yourBean.refresh}"/>4) Add a call to a javascript function like the following in your <afh:body>'s "onload" tag:
    function refreshPage() {
        var refreshComp;
        if (document.getElementById)
            refreshComp = document.getElementById("refresh");
        else if (document.all)
            refreshComp = document.all["refresh"];
        else if (document.layers)
            refreshComp = document.layers["refresh"];
        if (refreshComp) {
          refreshComp.click();
    }(All of that rigmarole is to support different browsers, which have different ways of retrieving a DOM element by its id.)
    5) For each component you need refreshed on a back button, set (or add) "refresh" to its partialTriggers property.
    6) Sit back and watch the Back button work.

  • IE and the back-button

    Hi all...
    I've used JHeadstart 10.1.2 to build a fairly simple UIX based web application. This application is completely a read-only view of some data, layed out as master-detail-detail over a few screens.
    As such, I followed the directions in the JHeadstart Dev Guide to disable back-button protection, since my application didn't need to be protected against misuse of the browser back button.
    Everything works fine in Firefox... users can query the master screen and drilled into details, and use the browser back button to back out of the details to the master page.
    However, IE does not like this at all. It intercepts this back-button use with pages that employ POST form submissions by throwing the following rendering when navigating back up from my app's details pages:
    ================
    Warning: Page has Expired The page you requested was created using information you submitted in a form. This page is no longer available. As a security precaution, Internet Explorer does not automatically resubmit your information for you.
    To resubmit your information and view this Web page, click the Refresh button.
    ================
    What kind of mods in my UIX/Struts JHeadstart code can I make in order for IE to accept use of the back-button in this scenario?
    I realize I can add breadcrumbs to my application, but that doesn't necessarily mean that the users will use this instead of the back button (especially since the users will be public anonymous Internet users -- training is not an issue)?

    Timothy,
    If you google on "how to prevent Warning: Page has Expired" you will find lots of useful links. You nee dto set your caching policy on the http header. You can do this by overriding JhsActionServlet.process, and register your custom action servlet in web.xml.
    You can add calls like this to set caching strategies:
    response.addHeader("Cache-Control", "max-age=3600");
    response.addHeader("Cache-Control", "private");
    Google on "response.setHeader" or reponse.addHeader for more examples.
    Steven Davelaar,
    JHeadstart Team.

  • Firefox Tabs and the Back Button

    I open a page (such as a Google search) in the first tab. I select any entry. When I press the BACK button, the browser (correctly) returns to the Google selection list. If I do the same in any other tab (2 thru nn), the Back button does not return me to the list. Does anyone else experience this? Bug? Feature? I've checked my add-ons, to no avail. This happens in both 3.6 and 4.0, and is not solely related to Google. (And this works OK in IE8.)

    Firefox 4 saves the previous session automatically, so there is no longer need for the dialog asking if you want to save the current session.<br />
    You can use "Firefox > History > Restore Previous Session" to get the previous session at any time.<br />
    There is also a "Restore Previous Session" button on the default <b>about:home</b> Home page.
    Another possibility is to use:
    * [http://kb.mozillazine.org/Menu_differences Firefox (Tools) > Options] > General > Startup: "When Firefox Starts": "Show my windows and tabs from last time"
    Do you still have the Bookmarks Toolbar visible?
    * [[Restore the default Smart Bookmarks Folders]]
    Check that you still have the "Bookmarks Toolbar items" placed on the Bookmarks Toolbar
    If the menu bar is hidden then press F10 or hold down the Alt key, that should make the "Menu Bar" appear
    Make sure that you have the Bookmarks Toolbar and the Navigation Toolbar visible: "View > Toolbars"
    Open the Customize window via "View > Toolbars > Customize" or via "Firefox > Options > Toolbar Layout"
    * Check in "View > Toolbars > Customize" that the "Bookmarks Toolbar items" is on the Bookmarks Toolbar
    * If the "Bookmarks Toolbar items" is not on the Bookmarks Toolbar then drag it back from the Customize window onto the Bookmarks Toolbar
    * If you do not see the "Bookmarks Toolbar items" or other items that are missing in the toolbar palette or on a toolbar then click the "Restore Default Set" button
    See also:
    * http://kb.mozillazine.org/Toolbar_customization

  • Call transaction MMBE from another program and press Back button

    Hello,
    I have program that is used as a 'launch pad' for some of our heavily used transactions. When I call the main 'launch pad' program, the user will select a button and a Call Transaction MMBE is initiated (USING the first screen). The user selects a material for display and presses the execute button (F8). The material overview is displayed correctly.  When the user presses the Back button (F12), transaction returns all the way back to the first called program and not to the first screen for transaction MMBE as expected.
    Does anyone know how I can change the screen flow and go back to the fist screen of MMBE and not the screen of the first called program?
    Regards,
    RC

    Rod,
    In your case i think it is not possible as it is standard functionality by SAP.
    Try work around, may be modification to the program will work.
    Regards,
    Amey

Maybe you are looking for