While developing an ADF Mobile application for Android/IOS, you may require to capture the device back button on user click. Here we will add little logic to exit the application once the user clicks on device back button.
We can directly use the phone gap backbutton api to override the default back button behaviour, you can register an event listener for the 'backbutton' event. It is no longer necessary to call any other method to over ride the back button behaviour. Now, you only need to register an event listener for 'backbutton'.
Application screen looks like below when it is deployed and run on the Android Device/Emulator. Click on the device back button will launch the confirm dialog, user can click OK to exit the application.
You can download the sample workspace from here. I have checked in Android Device/Emulator and it's working fine, not sure in IOS device.
Implementation Steps
Create an ADF Mobile Application, the application consists of two projects. Application Controller project of Application LifeCycle, Listeners, Device Features DataControl and ViewController project contains mobile features content like AMX Files, Task Flows and DataControl.
Right click on the ViewController project and in New Gallery window, select Web Tier-> HTML -> JavaScript File and name as "index.js". Next locate and expand the Application Sources folder, then expand the META-INF folder. You will see the adfmf-feature.xml file, click on the adfmf-feature.xml file to launch the Feature editor. Add a new feature by clicking the green plus sign on the Features table near top of the editor this will launch the new Create ADF Mobile Feature dialog, leave the default values and click ok.
In the Features table, select the newly created feature "feature1". Under the Features table, click the Content tab, and locate the Content table. Notice that the content item feature1.1 is created by default. Next add a new file by clicking the green plus sign and select ADF Mobile AMX Page, this will launch the new Create ADF Mobile AMX Page dialog, modify the File Name as index.amx.
Next in Includes section, click the green plus sign and Insert Include the javascript file as shown below.
Open the index.js file and below code catches the event that fires when the user presses the device back button.
We can directly use the phone gap backbutton api to override the default back button behaviour, you can register an event listener for the 'backbutton' event. It is no longer necessary to call any other method to over ride the back button behaviour. Now, you only need to register an event listener for 'backbutton'.
Application screen looks like below when it is deployed and run on the Android Device/Emulator. Click on the device back button will launch the confirm dialog, user can click OK to exit the application.
You can download the sample workspace from here. I have checked in Android Device/Emulator and it's working fine, not sure in IOS device.
Implementation Steps
Create an ADF Mobile Application, the application consists of two projects. Application Controller project of Application LifeCycle, Listeners, Device Features DataControl and ViewController project contains mobile features content like AMX Files, Task Flows and DataControl.
Right click on the ViewController project and in New Gallery window, select Web Tier-> HTML -> JavaScript File and name as "index.js". Next locate and expand the Application Sources folder, then expand the META-INF folder. You will see the adfmf-feature.xml file, click on the adfmf-feature.xml file to launch the Feature editor. Add a new feature by clicking the green plus sign on the Features table near top of the editor this will launch the new Create ADF Mobile Feature dialog, leave the default values and click ok.
In the Features table, select the newly created feature "feature1". Under the Features table, click the Content tab, and locate the Content table. Notice that the content item feature1.1 is created by default. Next add a new file by clicking the green plus sign and select ADF Mobile AMX Page, this will launch the new Create ADF Mobile AMX Page dialog, modify the File Name as index.amx.
Next in Includes section, click the green plus sign and Insert Include the javascript file as shown below.
Open the index.js file and below code catches the event that fires when the user presses the device back button.
//This is an event that fires when the user presses the device back button
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
document.addEventListener("backbutton", backKeyDown, true);
}
function backKeyDown() {
var cFirm = confirm("Are you sure you want to exit the application?");
if (cFirm == true) {
//Code to exit the application
navigator.app.exitApp();
}
}
Thank you for the post, it was very helpful. Unfortunately, that doesn't seem to work when the feature is pointing to a taskflow, not to an amx page. Any ideas? Thanks!
ReplyDeleteHi,
DeleteThis work fine when the feature is pointing to a taskflow also. Please see the http://deepakcs.blogspot.in/2013/04/sync-device-back-button-with-adf-mobile.html article, I have explained back button with taskflow scenario.
-Deepak
Thank you for the post, its very informative. I like it.
ReplyDeleteLoved this post. Thanks for sharing your day!
ReplyDeleteHi,
ReplyDeleteHow can I only assign a JS file to only one amx page? but my amx page is in a taskflow but I dont want to apply this behavior to all pages in a taskflow?
Hi Diego,
Delete//Check the device back button action happened in particular amx page
//Here "Id" is the amx:panelPage Id
if ($('#Id').length) {
//To do code
}
You can check this article - http://deepakcs.blogspot.sg/2013/04/sync-device-back-button-with-adf-mobile.html
- Deepak
I appreciate with the your post.
ReplyDeleteMobile Application
Thanks for sharing such types of informative blog. can you detailed summarized about Mobile Applications in next your blog publish.
ReplyDeleteThanks for the post but If i want the application to be removed from the memory and closed if i've pressed the Home button.
ReplyDeletelike banking application i want it to be removed from the momory
I appreciate from this post thanks for sharing with us. Its seems looking so good.
ReplyDeleteI am awed by the nature of data on Marketing Your Mobile App. There are a ton of great assets here. I am certain I will visit this online journal again soon.windows mobile app // iPhone app maker // mobile app developers
ReplyDeleteHi again!
ReplyDeleteHow can I invoke a java method from that javascript method?
I have a commandbutton which goes back to the previous page, but I would like to do that using the nativa back button also.
Thank you!
Diego,
ReplyDeleteYou can call the java method in javascript like below:
adf.mf.api.invokeMethod("mobile.TestBean", "sayHello", onSuccess, onFail);
mobile - PackageName
TestBean - Managed Bean
sayHello - Method in the managed bean
onSuccess, onFail - Javascript callback functions
Deepak,
DeleteI did that and it called the java method, BUT now I need that button to go back to the previous page I tried returning "__back" but it didn't work any ideas on how to use the device native back button to do that?
I soon as I posted this: I found the solution here: http://goo.gl/loUA1U
DeleteUsing: adf.mf.api.amx.doNavigation(“__back”);
Thanks Deepak!
I added you to my google circles hope you don't mind
Cool.. Thanks for adding to google circles.
DeleteYou have posted the blogs are really fantastic and informative.
ReplyDeleteMobile App Button
Excellent post!!! Java is most popular and efficient programming language available in the market today. It helps developers to create stunning desktop/web applications loaded with stunning functionalities. JAVA Training in Chennai | JAVA Training Institutes in Chennai
ReplyDeleteI known the lot of information and how it works then what are benefits by applying this application through this article.A great thanks for a valuable information.
ReplyDeleteAndroid Training in chennai | Android Training chennai | Android course in chennai | Android course chennai
Deepak,
ReplyDeleteNice post! but how to click device back button using javascript?
Hi, I am Emi lives in Chennai. I am technology freak. I did Android mobile application development course in Chennai at reputed training institutes, this is very usful for me to make a bright carrer in IT industry. So If you looking for best Android Training Institutes in Chennai please visit fita academy. Android Training in Chennai
ReplyDelete
ReplyDeleteThanks for sharing this valuable information to our vision. You have posted a trust worthy blog keep sharing.Nice article i was really impressed by seeing this article, it was very interesting and it is very useful for me.. Android Training in chennai | Android Training chennai | Android course in chennai | Android course chennai
Thanks for your informative article on ios mobile application development. Your article helped me to explore the future of mobile apps developers. Having sound knowledge on mobile application development will help you to float in mobile application development. iOS Training in Chennai
ReplyDeleteGreat Article
ReplyDeleteOnline Java Training | Java Training in Chennai | Java 360
All are saying the same thing repeatedly, but in your blog I had a chance to get some useful and unique information, I love your writing style very much, I would like to suggest your blog in my dude circle, so keep on updates…
ReplyDeleteRegards
Angularjs training in chennai|Angularjs training chennai|Angularjs course in chennai
Hardware and Networking Training in Chennai
ReplyDeleteCCNA Training in Chennai
AWS Training in Chennai
SAP Training in Chennai
Software Testing Training in Chennai
Java Training in Chennai
SAP Training in Chennai
I really enjoy simply reading all of your weblogs. Simply wanted to inform you that you have people like me who appreciate your work. Definitely a great post. Hats off to you! The information that you have provided is very helpful.
ReplyDeletemachine learning course
artificial intelligence course in mumbai
360DigiTMG is the best one in Hyderabad and is a Registered Education Provider (R.E.P.) by PMI to conduct training for this globally recognized certification.
ReplyDelete360DigiTMG pmp certification
pmi acp certification
I got more useful information from this thanks for share this blog
ReplyDeleteSpoken English Classes in Bangalore
Spoken English Classes in Chennai
Spoken English Classes in BTM
Spoken English Classes in Marathahalli
Spoken English Classes near Marathahalli
Spoken English Marathahalli
DevOps Training in Bangalore
PHP Training in Bangalore
Data Science Courses in Bangalore
English Speaking Course in Bangalore
Marvellous
ReplyDeleteSAP Training in Chennai
Java Training in Chennai
CCNA Training in Chennai
Pearson Vue Exam Center in Chennai
QTP Training in Chennai
Selenium Training in Chennai
Hardware and Networking Training in Chennai
SAP ABAP Training in Chennai
SAP FICO Training in Chennai
AWS Training in Chennai
Great information...
ReplyDeleteIntern Ship In Chennai
Inplant Training In Chennai
Internship For CSE Students
Online Internships
Coronavirus Update
Internship For MBA Students
iot internship
Great Post....
ReplyDeletecoronavirus update
inplant training in chennai
inplant training
inplant training in chennai for cse
inplant training in chennai for ece
inplant training in chennai for eee
inplant training in chennai for mechanical
internship in chennai
online internship
Great post......
ReplyDeleteIntern Ship In Chennai
Inplant Training In Chennai
Internship For CSE Students
Coronavirus Update
Online Internships
Internship For MBA Students
ITO Internship
Very Good Post..
ReplyDeleteSAP training in Chennai
AWS training in Chennai
Hardware and Networking training in Chennai
CCNA training in Chennai
QTP training in Chennai
Great Blog. Thnaks.
ReplyDeleteSAP Training in Chennai
Java Training in Chennai
Software Testing Training in Chennai
.Net Training in Chennai
Hardware and Networking Training in Chennai
AWS Training in Chennai
Azure Training in Chennai
Selenium Training in Chennai
QTP Training in Chennai
Android Training in Chennai
This blog is the general information for the feature. You got a good work for these blog.We have a developing our creative content of this mind.Thank you for this blog. This for very interesting and useful.
ReplyDeleteArtificial Intelligence Training in Chennai
Ai Training in Chennai
Artificial Intelligence training in Bangalore
Ai Training in Bangalore
Artificial Intelligence Training in Hyderabad | Certification | ai training in hyderabad
Artificial Intelligence Online Training
Ai Online Training
Blue Prism Training in Chennai
Thank you for sharing such a really admire your post. Your post is great!
ReplyDeletedata science course in Hyderabad
This is the first & best article to make me satisfied by presenting good content. I feel so happy and delighted. Thank you so much for this article.Java training in Chennai
ReplyDeleteJava Online training in Chennai
Java Course in Chennai
Best JAVA Training Institutes in Chennai
Java training in Bangalore
Java training in Hyderabad
Java Training in Coimbatore
Java Training
Java Online Training
The data that you provided in the blog is informative and effective.I am happy to visit and read useful articles here. I hope you continue to do the sharing through the post to the reader. Read more about
ReplyDeleteselenium training in chennai
selenium training in chennai
selenium online training in chennai
selenium training in bangalore
selenium training in hyderabad
selenium training in coimbatore
selenium online training
I just got to this amazing site not long ago. I was actually captured with the piece of resources you have got here.
ReplyDeleteangular js training in chennai
angular training in chennai
angular js online training in chennai
angular js training in bangalore
angular js training in hyderabad
angular js training in coimbatore
angular js training
angular js online training
Positive site, where did u come up with the information on this posting?I have read a few of the articles on your website now, and I really like your style.
ReplyDeleteangular js training in chennai
angular training in chennai
angular js online training in chennai
angular js training in bangalore
angular js training in hyderabad
angular js training in coimbatore
angular js training
angular js online training
Positive site, where did u come up with the information on this posting?I have read a few of the articles on your website now, and I really like your style. Thanks a million and please keep up the effective work.
ReplyDeleteDevOps Training in Chennai
DevOps Online Training in Chennai
DevOps Training in Bangalore
DevOps Training in Hyderabad
DevOps Training in Coimbatore
DevOps Training
DevOps Online Training
Great site and a great topic as well I really get amazed to read this.I gained many unknown information, the way you have clearly explained is really fantastic.It was very interesting and meaningful.keep posting such useful information.
ReplyDeleteFull Stack Training in Chennai | Certification | Online Training Course
Full Stack Training in Bangalore | Certification | Online Training Course
Full Stack Training in Hyderabad | Certification | Online Training Course
Full Stack Developer Training in Chennai | Mean Stack Developer Training in Chennai
Full Stack Training
Full Stack Online Training
This is a very useful blog.we are knowing a great content and also lots of information.
ReplyDeleteWeb Designing Training in Chennai
Web Designing Course in Chennai
Web Designing Training in Bangalore
Web Designing Course in Bangalore
Web Designing Training in Hyderabad
Web Designing Course in Hyderabad
Web Designing Training in Coimbatore
Web Designing Training
Web Designing Online Training
I known the lot of information and how it works then what are benefits by applying this application through this article.
ReplyDeleteacte chennai
acte complaints
acte reviews
acte trainer complaints
acte trainer reviews
acte velachery reviews complaints
acte tambaram reviews complaints
acte anna nagar reviews complaints
acte porur reviews complaints
acte omr reviews complaints
I known the lot of information and how it works then what are benefits by applying this application through this article.A great thanks for a valuable information.
ReplyDeleteAWS Course in Bangalore
AWS Course in Hyderabad
AWS Course in Coimbatore
AWS Course
AWS Certification Course
AWS Certification Training
AWS Online Training
AWS Training
Great post!I am actually getting ready to across this information,i am very happy to this commands.Also great blog here with all of the valuable information you have.Well done,its a great knowledge.
ReplyDeleteIELTS Coaching in chennai
German Classes in Chennai
GRE Coaching Classes in Chennai
TOEFL Coaching in Chennai
spoken english classes in chennai | Communication training
Excellent post. I learned a lot from this blog and I suggest my friends to visit your blog to learn new concept about technology.Best data science courses in hyerabad
ReplyDeleteThank you for providing this kind of useful information,I am searching for this kind of useful information; it is very useful to me and some other looking for it. It is very helpful to who are searching
ReplyDeleteAI Training in Hyderabad
Very useful blog with unique content and excellent writing thank you.
ReplyDeletetypeerror nonetype object is not subscriptable
Excellent blog information shared was very informative looking forward for next blog thank you.
ReplyDeleteData Analytics Course Online
Thanks for sharing this great information on Oracle ADF. Actually I was looking for the same information on internet for Oracle ADF Interview Questions and Answers/Tips and came across your blog. I am impressed by the information that you have on this blog. It shows how well you understand this subject, you can learn more aboutOracle ADF by attending Oracle ADF Training.
ReplyDeleteI curious more interest in some of them hope you will give more information on this topics in your next articles.
ReplyDeletedata science training
If all the writers who pen down articles would give a thought to write topic specific articles like you, then more number of readers would read their content.
ReplyDeleteSAP training in Mumbai
SAP course in Mumbai
Great experience I got good information from your blog.
ReplyDeletephp 7 performance
advertising tips
big data use cases in manufacturing
user licenses in salesforce
android interview questions for fresher
ReplyDeleteVery awesome!!! When I searched for this I found this website at the top of all blogs in search engines.
Data Science Training in Hyderabad
Through this post, i do know that your smart information in fiddling with all the items was very useful. I advise that this can be the primary place wherever I notice problems i have been sorting out. you've got a creative nevertheless engaging approach of writing.
ReplyDeletedata scientists training
David Forbes is president of Alliance Marketing Associates IncIamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder
ReplyDeleteSuch a great blog.Thanks for sharing...
ReplyDeleteDevOps Training in Bangalore
Devops Training in Pune
Devops Training in Hyderabad
Devops Training in Gurgaon
Annabelle loves to write and has been doing so for many years.Backlink Indexer My GPL Store Teckum-All about Knowledge
ReplyDeleteNeurobion Forte Tablet tablet use in multi vitamin see details
ReplyDeleteVery nice job... Thanks for sharing this amazing and educative blog post!
ReplyDeletedata science training in malaysia
Informative blog. Useful to many people. Thanks for sharing with us.
ReplyDeleteData Science Training Institute in Hyderabad
Such a good post .thanks for sharing
ReplyDeletePython Training in Porur
Python training in chennai
Interesting post. I Have Been wondering about this issue, so thanks for posting. Pretty cool post.It 's really very nice and Useful post.Thanks
ReplyDeletefull stack web development course in malaysia
Любой желает узнать свое будущее и воспринимает конкретные варианты гадания более достоверными. Гадания на сердце на картах это способ просмотреть грядущие события непрерывно привлекал человека. Ворожение позволяет просмотреть, что человека ожидает в предстоящее время.
ReplyDeleteJust pure brilliance from you here. I have never expected something less than this from you and you have not disappointed me at all. I suppose you will keep the quality work going on.
ReplyDeletedata science classes in hyderabad
Thank you for helping people get the information they need. Great stuff as usual. Keep up the great work!!!
ReplyDeletefull stack developer course
I will truly value the essayist's decision for picking this magnificent article fitting to my matter.Here is a profound depiction about the article matter which helped me more.
ReplyDeletedata science online training in hyderabad
The Kashmir Files Full Movie Download Filmyzilla
ReplyDeletebatman movie download in hindi filmyzilla
Wonder Woman 1984 Full Movie Download in Hindi Filmyzilla
Silence Movie Download in Hindi Filmyzilla
RRR Movie Download in Hindi 480p Filmyzilla
The Matrix Resurrections Movie Download Filmyzilla
kgf chapter 2 full movie in hindi download filmyzilla
Well stated, you have furnished the right information that will be useful to everybody. Thank you for sharing your thoughts. Security measures protect your company not only from data breaches, but also from excessive financial losses, a loss of people's trust, and potential risks to brand reputation and future benefits.
ReplyDeleteSD Wan Service Providers SOC service providers
SIEM solutions
Are you looking for a Data Analytics Course with placement assistance that can help you in landing a high-paying job then 360DigTMG is the right place for you. Enroll now
ReplyDeleteBest Data Science Training institute in Bangalore
Get Data Science Certification from top-ranked universities UTM, Malaysia, and IBM. We provide extensive training for the future-ready workforce.
ReplyDeletedata science training in malaysia
betmatik
ReplyDeletekralbet
betpark
mobil ödeme bahis
tipobet
slot siteleri
kibris bahis siteleri
poker siteleri
bonus veren siteler
TPX
Latest Egg Rates in India With The Help Of Egg Rates Price
ReplyDeleteAddress similar born newspaper agree arm. Push majority involve page forget.health
ReplyDeleteOccur form view safe second owner check. Kitchen thought audience blood do hard single.trending-updates
ReplyDelete