While working on ADF mobile application with offline/online capabilities, before calling webservices network has to be checked whether it is "connected" or "disconnected".
In my previous article Offline Data Synchronization for ADF Mobile, I was using the javascript to evaluate the network connectivity and store the connection status in pageFlowScope variable. But after subsequent checks pageFlowScope variable was not refreshing properly. Please see the oracle forum for more info, ADF Mobile - Get network status.
Steps to check network status dynamically:-
1. Java Script to check the network status
Enable the Mobile Data or Wireless and click on the Check button, Connection Type and Network Status will be displayed on the screen.
You can download the sample workspace from here
[Runs with Oracle JDeveloper 11.1.2.4.0]
In my previous article Offline Data Synchronization for ADF Mobile, I was using the javascript to evaluate the network connectivity and store the connection status in pageFlowScope variable. But after subsequent checks pageFlowScope variable was not refreshing properly. Please see the oracle forum for more info, ADF Mobile - Get network status.
Steps to check network status dynamically:-
1. Java Script to check the network status
/**
* Method to check the network status
*/
application.checkConnection = function () {
var isConnected;
var connectionType = navigator.network.connection.type;
var states = {
};
states[Connection.UNKNOWN] = 'Unknown connection';
states[Connection.ETHERNET] = 'Ethernet connection';
states[Connection.WIFI] = 'WiFi connection';
states[Connection.CELL_2G] = 'Cell 2G connection';
states[Connection.CELL_3G] = 'Cell 3G connection';
states[Connection.CELL_4G] = 'Cell 4G connection';
states[Connection.NONE] = 'No network connection';
if (connectionType == Connection.NONE || connectionType == Connection.UNKNOWN) {
isConnected = false;
}else {
isConnected = true;
}
var obj = {connectionType : connectionType, isConnected : isConnected};
return obj;
}
2. In managed bean call the application.checkConnection methodpublic void checkNetworkStatusAction(ActionEvent actionEvent) {
String networkDetails = (String)AdfmfContainerUtilities.invokeContainerJavaScriptFunction(AdfmfJavaUtilities.getFeatureName(),"application.checkConnection",new Object[] { });
try {
JSONObject obj = new JSONObject(networkDetails);
String connectionType = (String)obj.getString("connectionType");
boolean isConnected = (boolean)obj.getBoolean("isConnected");
setIsConnected(isConnected);
setConnectionType(connectionType);
} catch (JSONException e) {
throw new AdfException("Error while trying to connect to network", AdfException.ERROR);
}
}
Application screen looks like below when it deployed to Android device, When there is no network available in the device.Enable the Mobile Data or Wireless and click on the Check button, Connection Type and Network Status will be displayed on the screen.
You can download the sample workspace from here
[Runs with Oracle JDeveloper 11.1.2.4.0]
Now available is the mobile app for iPhone. Please visit this link to add the app: ahtcast mobile for iPhone.cell phone tracking app
ReplyDeleteDeepak,
ReplyDeleteIn the new Mobile application framework release, you no longer need this Javascript. If you use the EL expression it will dynamicsally refresh when connection status changes.
Steven Davelaar.
Thanks Steven.
DeleteDeepak,
ReplyDeleteHow to check whether the user is connected to vpn or not?
Hi Deepak,
ReplyDeleteI need to find connection type in moblie for which network type they are using. but we are not using ADF mobile.
We are using ADF and our application is responsive so that we have to check in mobiles.
Whether this approach is suitable to all (or) only ADF mobile???
Thanks,
Venkatesh Danduu
Great blog!! I hope you'll post a Data Science blog here.
ReplyDeletedata science course in delhi
I was looking at a portion of your posts on this site and I consider this site is really enlightening! Keep setting up..
ReplyDelete360DigiTMG supply chain analytics beginner's guide
Magnificent Information, I truly refreshing with it, This is fine to peruse and significant star potential, I truly bookmark it, professional expand read. Gratefulness genius sharing. I like it.
ReplyDelete"
hrdf claimable courses"
The information you have posted is important. The objections you have insinuated was worthy. Thankful for sharing.
ReplyDeletetraining provider in malaysia
It is an obligation of gratitude to share information, continue the great work ... I sincerely enjoy researching your website. great asset ...
ReplyDeletemasters in data science
Superbly written article, if only all bloggers offered the same content as you, the internet would be a far better place..
ReplyDeleteDigital Marketing Training Institutes in Hyderabad
Nice Blog !
ReplyDeleteQuickBooks is one such accounting software that is used to handle all the accounting tasks of an organization. In case you find any technical issue in QuickBooks, call us at QuickBooks Technical Support Phone Number 1-(855) 550-7546.
Incredibly conventional blog and articles. I am realy very happy to visit your blog. Directly I am found which I truly need. Thankful to you and keeping it together for your new post.
ReplyDeletedata science course gurgaon
Nice & Informative Blog !
ReplyDeleteIf you keep on seeing QuickBooks Error 2107 on your screen, call us on QuickBooks Support Number to get immediate technical consultation for QuickBooks issues.
What an amazing information you had listed in your blog about digital marketing that clears the doubts about digital marketing. I will also share this blog with my friends. For
ReplyDeletedigital marketing institute in aurangabad
Impressive blog post,
ReplyDeleteOur Digital Marketing Course with Internship Program consists of 35 Modules. With 1 Hr class everyday from Monday to Friday. You can join the internship along with the course for two months duration.
Digital Marketing Course with Internship