Languages

Menu
Sites
Language
How to check home button press?

Hi there,

How to check home button press?

I made web app.

This app using HTML5 <audio> tag. ( = backgroud sound.)

I was setted "background support = disable" in config.xml.

But When i pressed hardware home button, sound is playing.

So.. I have two question.

1. How to check home button press? 

(I want to stop background sound, when home button press.)

 

 

Or

2. How to check application onhide?

 

Thank you.

 

Edited by: Brock Boland on 17 Mar, 2014 Reason: Paragraph tags added automatically from tizen_format_fix module.

Responses

5 Replies
Vineet Tiwari
$("#page1").focusin(function (){ console.log("received focus In Event") ; }) $("#page1").focusout(function (){ console.log("received focus Out Event") ; }) give your page id as "page1" and add the above code snippet to your main.js inside init . hope it helps you
Noureen Akhter
Hi Vineet! Actually i am also facing same problem. Now i used your solution. Problem is that if i include header in my code then these function are called Like you can understand better from my code:

Single-Page 2 Application

//Initialize function var init = function () { // TODO:: Do your initialization job console.log("init() called"); $("#page1").focusin(function (){ console.log("received 1 focus In Event") ; }) $("#page1").focusout(function (){ console.log("received 1 focus Out Event") ; }) $("#fullpage").focusin(function (){ console.log("received 2 focus In Event") ; }) $("#fullpage").focusout(function (){ console.log("received 2 focus Out Event") ; }) }; $(document).ready(init); in this scenario i have two pages now one page is without header tag and other is with header . Now when i start my app on device page without header never calls focusin and focusout but the other with header calls focus in and focus out. Can you please guide me that which is the best place to call this again and again without header. In my case i want to stopt my animation. Here is the problem form which you can undertsand why i need these functions: https://developer.tizen.org/forums/web-application-development/animation-stop-problem
Yunchan Cho
Basically if you don't set 'background-support=enable' on config.xml, your webapp is stopped to execute on background until it goes to foreground. I don't know that sound playing that you said is a bug of tizen webkit. But when your webapp goes to background regardless of setting 'background-support', visibilitychange event is always sent to content of the webapp. So if you want to stop to play sound explicitly from web content, I recommend that you use this event properly. And could you explain second question more detail? Best Regards, Yunchan Cho.
Byron Gavras
Just use below code inside your javascript window.onblur = function() { console.log("blurred window"); } window.onfocus = function() { console.log("focus); }
Alexander AVSukhov
Hi, You may try to use webkitvisibilitychange event. For more information see: https://developer.tizen.org/ru/documentation/articles/application-visibility?langredirect=1