render :back => :close is not working in Rhodes-4.0.beta.59 version

HI All,

I am facing issue with handling device back button in android Rhodes-4.0.beta.59 version.

I am displaying the Login page as render :action => :login, :back => :close so that when user clicks back key on device when on Login page it closes the application.

But the same thing fails in the below scenario:

1. Enter valid details in Login page,

  Controller method is called which uses Async Post to call Authentication with backend. In callback displaying Home page

  Home page(say) is displayed.

2. Click Logout on Home page

3. Login page is displayed

4. Now click Android device "Back" button

7. Home page of Step 1 is displayed.

But as per code :back event is specified so it should close the app, but somehow Rhodes is maintaining history and I need to override it.

Please help to solve this issue.


Thanks in advance,

Vidyaa.N

Kutir Mobility
Hi Vidyaa,To my knowledge No,

Hi Vidyaa,

To my knowledge No, but I would wait to hear from Motorola dev team as well.

IMHO, You can validate the user name which is present or not and block home page if no user.

In rhoconfig, create a  global variable called USER_NAME = ""

After user login, save the user name at Rho::RhoConfig.USER_NAME as shown below,

Rho::RhoConfig.USER_NAME = "User Name"

  When you click logout, clear the user name as shown below,

Rho::RhoConfig.USER_NAME = ""

  Check Rho::RhoConfig.USER_NAME on home method as shown below,

  In Controller.rb

def home

   if Rho::RhoConfig.USER_NAME == ""

  redirect :action => :login

   else

  //Proceed with your other implementation code

   end

  end

  In view page

  <a href="#" class="ui-btn-right" data-icon="plus" onclick="go_login();">

      Logout

  </a>

  <script type="text/javascript">

      function go_login () {

        Rho.WebView.navigate("/app/TestBackBtn/login");

      }

    </script>

Let me know if it helpful to you.

Visnupriya R

Kutir Mobility

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Vidyaa Natarajan
Hi Visnupriya,Thanks for your

Hi Visnupriya,

Thanks for your timely support. We are using Offline login in my application and I am storing the login-username and login-password in Rhoconfig variables for offline access.

So we can't check with Rhoconfig variables. Is there any other solution for this?

Thanks in advance,

Vidyaa.N

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Kutir Mobility
Hi Vidyaa,You dont need to be

Hi Vidyaa,

You dont need to be online to use Rho::RhoConfig object.

Visnupriya

Kutir Mobility

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Vidyaa Natarajan
Hi Visnupriya,We are storing

Hi Visnupriya,

We are storing username and password in Rhoconfig variable for offline access of the application.

Thanks in advance,

Vidyaa.N

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Vidyaa Natarajan
Hi All,I have tried by giving

Hi All,

I have tried by giving System.exit while pressing the hardware back button, but its also not working in Rhodes-4.0 beta 59 version.

Is there any other solution to fix this issue?

Please help me to fix this issue.

Thanks in advance,

Vidyaa.N

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Anonymous (not verified)
Hi Vidyaa,You can override

Hi Vidyaa,

You can override the Android back button by using the Rho.KeyCapture module. I'm afraid I dont know Ruby well so my example is in JavaScript, but the semantics are the same.

//0x04 is the android hardware back key

Rho.KeyCapture.captureKey(false, "0x04", function(){

     Rho.Application.quit();

});

You can find more information on KeyCapture module here: http://edgedocs.rhomobile.com/api/keycapture#mcaptureKey

I hope this helps. Best regards,

Ben

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Vidyaa Natarajan
Hi Benedict Kennedy,Thanks

Hi Benedict Kennedy,

Thanks for your timely support.

For Rhodes-3.3.3 versions, for the android hardware back button by referring to the Rhomobile documents I gave in the controller method as

render :back => :close ( which worked and exits the application).

For Rhodes-4.0 beta versions, I gave the same code in the controller method as Rhodes-3.3.3 but didn't work.

I referred to the Keycapture link given by you and gave the necessary extensions in build.yml. But when I call the javascript method from the :back via a method in controller, the method is not called and the Keycapture function is also not called.

How to call the Keycapture function from render :back in controller?

Please help me to fix this issue.

Thanks in advance,

Vidyaa.N

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


charles plasse
Hi All,Anyone from Rhomobile

Hi All,

Anyone from Rhomobile could help on this issue ?

Thanks for your support

Best

Charles

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Vidyaa Natarajan
Hi All,Thanks for your

Hi All,

Thanks for your support.

I am using Rhodes-4.0 beta 59 version for my application. In Android, after logout when I click on the Android device hardware "back" button the application is not exiting.

By referring to the Rhomobile documents I have tried the following codes in my controller,

1) render :back => :close  

          -> not working in Rhodes-4.0.beta.59 version

          -> worked in Rhodes-3.3.3

2) Rho::KeyCapture.captureKey true, 'ALL', url_for(:action => :keyCallback)

     def keyCallback

        Rho::Log("this key has just been pressed!: " + @params["keyValue"],"APP")

     end

     I have added the extensions: ["hardwarekeys"] in build.yml


          -> But it is not working in Rhodes-4.0 beta 59 version. I am getting the error as "KeyCapture is not a function".

Please help me to fix this issue.

Thanks in advance,

Vidyaa.N

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Robert Galvin
Please upgrade to the

Please upgrade to the released version it is available for download.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Vidyaa Natarajan
Hi All,I have upgraded the

Hi All,

I have upgraded the latest Rhode-4.0 version. I have the android hardware back button issue with the Rhodes-4.0 beta 59 version, but I am having the same issue in latest Rhodes-4.0.

I have given the code Rho::KeyCapture.captureKey true, 'ALL', url_for(:action => :keyCallback) in controller file, but I am getting the error as "KeyCapture is not a function".


I have also included the "hardwarekeys" extension in build.yml.

Please help me to fix this issue. Please provide me with a sample code.

Thanks in advance,

Vidyaa.N

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Kutir Mobility
Hi Vidyaa,There is a sample

Hi Vidyaa,

There is a sample application called KitchenSink with examples of using most of the new 4.0 APIs. You can find it at https://github.com/rhomobile/rho-samples under the "kitchensink" folder. Among others, it contains an example of using KeyCapture to capture all keys, as you are trying to do here.

Javier

Kutir Mobility

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Robin West
Hi Javier,Thanks for your

Hi Javier,

Thanks for your support. I saw the code in KitchenSink examples and tried in my Rhodes project. But I am getting the error as,

"Uninitialized constant Rho::KeyCapture.captureKey".

I have included all the necessary extensions n build.yml also, but I am getting the above error.

To use the KeyCapture constant which is a Rhoelement component, is that we need to buy any license key?


Please help me on this issue.

Thanks,

Vidyaa.N

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Kutir Mobility
Hi Vidyaa, Yes, you need a

Hi Vidyaa,

Yes, you need a license to use KeyCapture API.

Please see http://edgedocs.rhomobile.com/guide/apisummary.


Visnupriya R

Kutir Mobility

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Log in to post comments