Learning Android Intents
Muhammad Usama bin Aftab, Wajahat Karim
Format: PDF / Kindle (mobi) / ePub
Explore and apply the power of intents in Android application development
About This Book
- Understand Android Intents to make application development quicker and easier
- Categorize and implement various kinds of Intents in your application
- Perform data manipulation within Android applications
Who This Book Is For
If you are a novice or an intermediate Android Developer who wants to expand their knowledge of Android Intents, this book is ideal for you. Readers are expected to have basic understanding of Android development, how to use different IDEs, and how to develop applications using Android APIs.
What You Will Learn
- Understand Android Intents and their importance in Android apps
- Get to grips with the different types of Intents and their implementation
- Discover data transfer methods in Android Intents along with their optimization and performance comparisons
- Explore the implementation of Intents while invoking Android Features in an application.
- Use Intent Filters and their sub-domains in order to perform various actions and sorting categories in Android Intents
- Catch different events while working with Broadcast Receiver and perform various actions
- Implement pending Intents and Intent Service, sending text to the Notification Panel, and much more
Android is an emerging technology with loads of apps in the Google Play Market. Till date, it is the biggest marvel in Smartphone technology, propelling a larger number of developers into Android application development. Intent is an essential part of any Android Application and no Android application is complete without using them. Features such as listening broadcasts, sending messages, sharing via social networks, notifications, hardware components including camera, sensors, Wi-Fi, and more, can be used in your applications by using Intents.
This practical guide focuses on using intents to make the best use of various features of Android platform. It is ideal for those developers who want to understand the backbone and the domain of Android Intents, its power, and the need for it inside an Android application. Practical, in-depth examples are used throughout the book, to help you understand the key concepts.
The book starts with introducing the very basic concepts of Android, and its various facts and figures such as different Android versions, their release dates, evolution of Android phones and so on. While covering the basic technical concepts, it proceeds from the easiest route of introducing Android Intents towards the more practical view of Android Intents in terms of components and features.
You will learn how to use different components and features such as transfer data between activities, invoke various features and components of Android, execute different in-built and custom-made services, use hardware and software components of Android device, and start Pending Intents & notifications. You will gain better theoretical knowledge of what is running behind the concepts of Android Intents, and practical knowledge of the mobile-efficient ways to perform a certain task using Android Intents.
Towards the end, you will have a clear vision and a practical grip on Android intents and its features. Learning Android Intents is a proper guide to give you the best knowledge of Intents.
Constants Component Description ACTION_CALL Activity Start the phone call ACTION_EDIT Activity Display the data of the user to edit ACTION_MAIN Activity Start as the initial activity with no data ACTION_SYNC Activity Sync the data present on the server with the mobile device ACTION_BATTERY_LOW Broadcast ReceiverShows the battery low warning ACTION_HEADSET_PLUG Broadcast ReceiverShows an alert when the headset is plugged in or unplugged ACTION_SCREEN_ON Broadcast
then why do we need services to create a thread? In Android OS, services are the standard method for doing background processing. When the Android OS becomes short on memory, it can stop the idle services to get their memory. But it can't stop the threads; so, using services is a better way of continuously performing tasks in the background. We are not doing anything in the onStartCommand() method except displaying a toast like other methods of the service class. There isn't any special point to
camera. And when we close the camera activity, it will come back to the original activity of our app and give us some result of the captured picture. So, to get the result in any activity, we have to override the onActivityResult() method. This method is called when the parent activity is started after the child activity is completed. When this method is called, it means that we have used the camera and are now back to our parent activity. If the result is successful, we can display the captured
method. We have put the extra object defining the video quality as high by assigning the MediaStore.EXTRA_VIDEO_QUALITY value to 1. Then, we pass the intent in the startActivityForResult() method again to start the camera activity. The next change is in the onActivityResult() method when we get the video from the intent. The following code shows some sample code to get the video and pass it in the VideoView tag and play it: [ 128 ] Chapter 4 In the case of taking a picture, we restored raw
relate to the source code of an Android project. In order to write an application, a developer needs to write some lines of code that will respond in the way the user wants. In coding components, the main folder that holds all of the developer's code is src. The folder consists of one or more Java packages in which developers classify their code in accordance with the type of work done. The default way to write a package name is dot separated (for example, com.app.myapplicationproject), which can