John Wiley & Sons, Inc. PROFESSIONAL. Mobile Application Development. Jeff McWherter. Scott Gowell mtn-i.info MOBILE APPLICATION. DEVELOPMENT. “The search for .. http://developer. mtn-i.info pdf. As of today we have 78,, eBooks for you to download for free. Learning Mobile App Development: A Hands-on Guide to Building Apps with iOS and.
|Language:||English, Spanish, German|
|Distribution:||Free* [*Registration needed]|
Looking for books on Mobile Application Development? Check our section of This page contains list of freely available E-books, Online Textbooks and Tutorials in Mobile Application Development. Building Mobile Applications ( PDF 15P). Android developers mtn-i.info • Books. – “Professional Android 4 Application. Development”, By Reto Meier. 9/2/ in preparing this book, they make no representations or warranties with respect to the accuracy HTML5 Mobile App Development with PhoneGap. Introduction.
After completing the employment requirement as a university professor in Indonesia, he decided to come back to teach in the US and chose West Michigan as the home for his family.
A few years ago he started a special section of Introduction to Computer Science II course opened to students who are interested in mobile application development using Android. Under his guidance, the students taking this special section have published several Android apps to the Google Play Store. Hans' interest in Android programming began since Cupcake and he continues to stay up-to-date with the latest release. Having research interests both in mobile applications and computer graphics has motivated him to learn Vulkan mobile-first , by exploring the library using Android NDK.
See full terms Authors, publishers and universities use Leanpub to publish amazing in-progress and completed books and courses, just like this one. You can use Leanpub to write, publish and sell your book or course as well! Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.
Leanpub is a magical typewriter for authors: It really is that easy. Learn more about writing on Leanpub. All rights reserved. Search Query. Created with Sketch. Sign In Sign Up. Reader feedback Feedback from our readers is always welcome.
Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of. If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www. Customer support Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your download.
Downloading the example code This book contains many code samples throughout the recipes. The GitHub repository may be updated as any possible typing mistakes are discovered in the book.
As a result, it is a possibility that the code may not exactly match the text in the book. If you are not familiar with GitHub, simply click on the Downloads tab and then either Download as zip or Download as tar. You can extract these files to any location on your local machine where you easily open them. Errata Although we have taken every care to ensure the accuracy of our content, mistakes do happen.
If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website, or added to any list of existing errata, under the Errata section of that title.
Piracy Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.
We appreciate your help in protecting our authors, and our ability to bring you valuable content. This chapter will explore how we can access these sensors and make use of this exposed functionality in helpful applications that can be built in any IDE using the PhoneGap API.
Movement and Location: Using the Accelerometer and Geolocation Sensors Detecting device movement using the accelerometer The accelerometer captures device motion in the x, y, and z -axis directions. The accelerometer is a motion sensor that detects the change delta in movement relative to the current device orientation.
How to do it We will use the accelerometer functionality from the PhoneGap API to monitor the feedback from the device: 1. First, create the initial HTML layout and include the required script reference to the cordova Include the onSuccess function to handle the returned information from the accelerometer.
Once ready, the application will call the getCurrentAcceleration method from the accelerometer API, providing two methods to handle successful transactions and errors respectively. The onSuccess function returns the obtained acceleration information in the form of the following four properties: ff 10 acceleration.
This is the movement from left to right when the device is placed with the screen facing an upright position. Positive acceleration is obtained as the device is moved to the right, whereas a negative movement is obtained when the device is moved to the left. Chapter 1 ff acceleration. This is the movement from bottom to top when the device is placed with the screen facing an upright position. Positive acceleration is obtained as the device is moved upwards, whereas a negative movement is obtained when the device is moved downwards.
This is a perpendicular from the face of the device. Positive acceleration is obtained when the device is moved to face towards the sky, whereas a negative movement is obtained when the device is pointed towards the Earth. This could be used to store, update, and track changes over a period of time since the last accelerometer update.
Accelerometer data obtained from the device has been used to a great effect in mobile handset games that require balance control and detection of movement including steering, control views, and tilting objects.
Adjusting the accelerometer sensor update interval The getCurrentAcceleration method obtains the data from the accelerometer at the time it was called — a single call to obtain a single response object.
In this recipe, we'll build an application that allows us to set an interval to obtain a constant update from the accelerometer to detect continual movement from the device. We will provide additional parameters to a new method available through the PhoneGap API to set the update interval: 1.
Firstly, create the initial HTML layout and include the required script reference to the cordova We'll now write the startWatch function.
Firstly, we'll create a variable called options to hold the optional frequency parameter, set to milliseconds three seconds. We will then set the initial disabled properties of two buttons that will allow the user to start and stop the acceleration detection.
Next we will assign the watchAcceleration to the previously defined watchID variable. This will allow us to check for a value or if it is still set to null.
With the startWatch function written, we now need to provide a method to stop the detection of the acceleration. This firstly checks the value of the watchID variable. If this is not null it will stop watching the acceleration using the clearWatch method, passing in the watchID parameter before resetting this variable back to null.
We then reference the accelerometer div element and set its value to a userfriendly message. Now we need to create the onSuccess method, which will be run after a successful update response. We assign the returned values from the acceleration object as the HTML within the accelerometer div element for display to the user.
We also need to supply the onError method to catch any possible issues with the request. Finally, we will add in the two button elements, both of which will have an onClick attribute set to either start or stop watching the device acceleration: Accelerometer Data start stop 15 Movement and Location: Using the Accelerometer and Geolocation Sensors Obtaining data The results will appear similar to the following screenshot: Stopping the acceleration watch will look something like the following screenshot: How it works Once ready, the application will call the startWatch function, within which the desired frequency interval for the acceleration updates is set.
If the interval is not passed through, it defaults to milliseconds ten seconds. Each time an update has been obtained, the onSuccess method is run to handle the data as you wish, in this case displaying the results on the screen. The watchID variable contains a reference to the watch interval and is used to stop the watching process by being passed in to the clearWatch method from the PhoneGap API.
There's more In this example the frequency value for the accelerometer update interval was set at milliseconds three seconds.
Consider writing a variation on this application that allows the user to manually change the interval value using a slider or by setting the desired value into an input box. Updating a display object position through accelerometer events Developers can make use of the accelerometer sensor and continual updates provided by it for many things including motion-detection games as well as updating the position of an object on the screen.
We will use the device's accelerometer sensor on continual update to move an element around the screen as a response to device movement. This is achieved through the following steps: 1. Let's start by creating our initial HTML layout.
The second div element will have the ID of accelerometerData and will be the container into which our returned acceleration data will be output: 17 Movement and Location: Using the Accelerometer and Geolocation Sensors Accelerometer Movement Accelerometer Movement Obtaining data We can now start with our custom scripting and PhoneGap implementation.
Add a script tag block before the closing head tag to house our code: Accelerometer Movement 5. Before we dive into the core code, we need to declare some variables.
With the request made to the device we now need to create the success and error handling methods. The onSuccess function is first, and this will deal with the movement of our object around the screen. The returned acceleration object contains the information we need regarding the position on the x and y axes of the device. We can now set the acceleration values for these two axis into our variables and work out the velocity for movement.
We need to ensure that our display object doesn't move out of sight and to keep it within the bounds of the screen: if xdocument. Now that we have the correct x and y coordinates we can apply them to the style of the dot element position. Our call to the accelerometer also requires the error handler, so let's write that now.
In this recipe we are easily changing the position of the dot element by calculating the correct X and Y axes to place it on the screen. We are also taking extra care to ensure that the element stays within the bounds of the screen by using some conditional statements to check the current position, the radius of the element, and the dimensions of the screen itself. See also ff The Detecting device movement using the accelerometer recipe Chapter 1 Obtaining device geolocation sensor information Geolocation and the use of Global Positioning Satellites GPS allow developers to create dynamic real-time mapping, positioning, and tracking applications.
Using the available geolocation methods we can retrieve a detailed set of information and properties to create location-aware applications. We can obtain the user's location if they are connected via the mobile data network or Wi-Fi. We will use the geolocation functionality from the PhoneGap API to monitor the feedback from the device and obtain the relevant location information: 1.
Let's now add the onDeviceReady function. This will execute the geolocation. Include the onSuccess function to handle the returned position object from the geolocation request. Let's then create a reference to the geolocationData div element and assign it to the variable geoElement, which will hold our generated position results.
Next we can assign the returned values as a formatted string, which we'll set as the HTML content within the geolocationData div element. Finally, let's include the onError function to handle any possible errors that may arise. Depending on the existence of an error, we will use the value of the returned error code to determine which message to display to the user. When we run the application on a device, the output will look something like the following screenshot: If we face any errors, the resulting output will look something like the following screenshot: 26 Chapter 1 How it works As soon as the device is ready and the native PhoneGap code has been initiated on the device, the application will execute the getCurrentPosition method from the geolocation API.
We have defined an onSuccess method to manage the output and handling of a successful response, and have also specified an onError method to catch any errors and act accordingly.
The onSuccess method returns the obtained geolocation information in the form of the position object, which contains the following properties: ff position. The properties available within the position object are quite comprehensive and detailed.
For those marked as 'optional', the value will be set and returned as null if the device cannot provide a value. The onError method returns a PositionError object if an error is detected during the request. This object contains the following two properties: ff code: A Number value that contains a numeric code for the error. The errors could relate to insufficient permissions needed to access the geolocation sensors on the device, the inability to locate the device due to issues with obtaining the necessary GPS information, a timeout on the request, or the occurrence of an unknown error.
Many modern browsers and devices already have this functionality enabled. If any device your application runs on already implements this specification, it will use the built-in support for the API and not PhoneGap's implementation. Adjusting the geolocation sensor update interval Through the use of the getCurrentPosition method, we can retrieve a single reference to the device location using GPS coordinates.
In this recipe, we'll create the functionality to obtain the current location based on a numeric interval to receive constant updated information. We are able to pass through an optional parameter containing various arguments to set up an interval and improve accuracy: 1.
Create the HTML layout for the application, including the required cordova2. Within this we'll declare a new variable called watchID. We can now create the startWatch function. Firstly, let's create the options variable to hold the optional parameters we can pass through to the method. Set the frequency value to milliseconds five seconds and set enableHighAccuracy to true.
Next we will assign the watchPosition method to the previously defined variable watchID. We'll use this variable to check if the location is currently being watched. With the initial call methods created, we can now write the onSuccess function, which is executed after a successful response. The position object from the response is sent through as an argument to the function. Declare some variables to store detailed information obtained from the response in the form of the timestamp, latitude, longitude, and accuracy variables.
We'll also create the element variable to reference the geolocationData div element, within which our information will be displayed. The returned information is then assigned to the relevant variables by accessing the properties from the position object. When we run the application, the output will be similar to the following screenshot: How it works The watchPosition method from the PhoneGap API runs as an asynchronous function, constantly checking for changes to the device's current position.
Once a change in position has been detected, it will return the current geographic location information in the form of the position object. With every successful request made on the continuous cycle, the onSuccess method is executed and formats the data for output onto the screen. There are three optional parameters that can be sent into either the getCurrentPosition or watchPosition method.
They are as follows: ff enableHighAccuracy: A Boolean value that specifies whether or not you would like to obtain the best possible location results from the request. By default false , the position will be retrieved using the mobile or cell network. If set to true, more accurate methods will be used to locate the device, for example, using satellite positioning. Android devices will not return a successful geolocation result unless enableHighAccuracy is set to true Clearing the interval The continual location requests can be stopped by the user or through the application using an interval timer by employing the use of the clearWatch method, available within the PhoneGap API.
Getting ready Before we can continue with coding the application in this recipe, we must first prepare the project and obtain access to the Google Maps services: 1. You will find the key displayed in the Simple API Access section of the page, as shown in the following screenshot: 4.
We can now proceed with the recipe. We'll use the device's GPS ability to obtain the geolocation coordinates, build and initialize the map canvas, and display the marker for our current position: 1.
Append your API key into the query string in the script src attribute. Next, add the cordova If we were only allowing the user to manually input coordinates without automatic detection this could have been set to false. However, we are using the data obtained from the device's sensor to automatically retrieve our location.
Let's take the latitude and longitude information obtained from the device geolocation sensor response and create a latLng object which we will send into the Map object when we initialize the component. We will then set the options for our Map, setting the center of it to the coordinates we set into the latLng variable. Not all of the Google Map controls translate well to the small screen, especially in terms of usability. We can define which controls we would like to use.
In this case we'll accept the zoomControl but not the panControl. To define the Map object itself we reference a div element and pass through the mapOptions variable we have previously declared.
LatLng position. Map document. With the body tag, let's include the div element into which the map will be displayed: Running the application on the device, the result will look similar to this: How it works Thanks to the use of exposed mapping services such as Google Maps we are able to perform geolocation updates from the device and use the obtained data to create rich, interactive visual mapping applications.
In this example, we centered the Map using the device coordinates and also created a Marker overlay to place upon the mark for easy visual reference.
The available APIs for mapping services such as this are incredibly detailed and contain many functions and methods to assist you in creating your location-based tools and applications. Some services also set limits on the amount of requests made to the API, so make sure you are aware of any restrictions in place. Explore the alternatives and experiment to see if a particular solution suits your application better than the others.
We did this so that we could use the zoom controls and provide our user with a certain level of interaction by being able to drag the map. As an alternative, you could use the Google Static Map service, which simplifies the code needed to generate a map, and will return a static image showing the location.
You can choose to use an API key with this service, but it is not required. By using the Static Map API, you lose the interactivity offered through the dynamic map, but you gain an incredibly simple, easy-to-use service that requires very little code to achieve results.