Android UI Development
1 - Introduction To Android Development Android is an operating system and programming platform developed by Google for mobile phones and other mobile devices, such as tablets. It can run on many different devices from many different manufacturers. Android includes a software development kit (SDK) that helps you write original code and assemble software modules to create apps for Android users. Android also provides a marketplace to distribute apps. All together, Android represents an ecosystem for mobile apps.As the world's most popular mobile platform, Android powers hundreds of millions of mobile devices in more than 190 countries around the world. It has the largest installed base of any mobile platform and is still growing fast. Every day another million users power up their Android-powered devices for the first time and start looking for apps, games, and other digital content.The Android home screen can contain several panes of app icons, which launch their associated apps. Home screen panes can also contain app widgets, which display live, auto-updating content such as the weather, the user's email inbox, or a news ticker. Android can also play multimedia content such as music, animation, and video. The figure above shows app icons on the home screen (left), playing music center, and displaying app widgets (right). Along the top of the screen is a status bar, showing information about the device and its connectivity. The Android home screen may be made up of several panes, and the user swipes back and forth between the panes.
Android is designed to provide immediate response to user input. Besides a dynamic interface that responds immediately to touch, an Android-powered device can vibrate to provide haptic feedback. Many apps take advantage of internal hardware such as accelerometers, gyroscopes, and proximity sensors to respond to additional user actions. These sensors can also detect screen rotation. For example, you could design a racing game where the user rotates the device as if it were a steering wheel.
The Android platform, based on the Linux Kernel, is designed primarily for touchscreen mobile devices such as mobile phones and tablets. Because Android-powered devices are usually battery-powered, Android is designed to manage processes to keep power consumption at a minimum, providing longer battery use.
2- What Is Fragment -Fragments introduce modularity and reusability into your activity’s UI by allowing you to divide the UI into discrete chunks. Activities are an ideal place to put global elements around your app's user interface, such as a navigation drawer. Conversely, fragments are better suited to define and manage the UI of a single screen or portion of a screen.
Consider an app that responds to various screen sizes. On larger screens, the app should display a static navigation drawer and a list in a grid layout. On smaller screens, the app should display a bottom navigation bar and a list in a linear layout. Managing all of these variations in the activity can be unwieldy. Separating the navigation elements from the content can make this process more manageable. The activity is then responsible for displaying the correct navigation UI while the fragment displays the list with the proper layout.
FragmentManager
manages the fragment back stack. At runtime, the FragmentManager
can perform back stack operations like adding or removing fragments in response to user interactions. Each set of changes are committed together as a single unit called a FragmentTransaction. For a more in-depth discussion about fragment transactions, see the fragment transaction guide.When the user presses the Back button on their device, or when you call Fragment management, the top-most fragment transaction is popped off of the stack. In other words, the transaction is reversed. If there are no more fragment transactions on the stack, and if you aren't using child fragments, the back event bubbles up to the activity. If you are using child fragments, see
When you call add ToBackStack() on a transaction, note that the transaction can include any number of operations, such as adding multiple fragments, replacing fragments in multiple containers, and so on. When the back stack is popped, all of these operations are reversed as a single atomic action. If you've committed additional transactions prior to the popBackStack()
call, and if you did not use addToBackStack()
for the transaction, these operations are not reversed. Therefore, within a single FragmentTransaction
, avoid interleaving transactions that affect the back stack with those that do not.
FragmentManager fragmentManager = getSupportFragmentManager();
fragmentManager.beginTransaction()
.replace(R.id.fragment_container, ExampleFragment.class, null)
.setReorderingAllowed(true)
.addToBackStack("name") // name can be null
.commit();
supportFragmentManager.commit {
replace<ExampleFragment>(R.id.fragment_container)
setReorderingAllowed(true)
addToBackStack("name") // name can be null}
There are solid reasons why java is used for android development.
The main objective behind Android development was to create a platform-independent application environment that can run on every device. As we know java already have this quality so java was chosen for android development. Android applications run on a special virtual machine called the Dalvik VM that is a direct inspiration from java virtual machine called JVM. Android application can run on any device where special Dalvik VM is implemented. These way android applications are compiled and run in optimum performance environment with the feature of platform independence.
The good approach towards software development is the object oriented approach. Java is based on the oops concept. Android relies heavily on Java fundamentals like classes and objects and its other useful features of oops.
Java has an extensive set of libraries. It is easy to take advantage of these libraries. Android SDK has many standard Java libraries included. These provide functionalities for data structure, math functions, graphics implantation, and networking functions and much more. These java libraries help us to do everything else we could want. This way java helps develop Android applications fast and inefficient manner.
Android is made to run on different platforms i.e. hardware platforms. Thus architectural neutrality is desired and necessary. Android code is written once and to execute need to compile and optimise native code for better performance on various devices. Java has platform independent feature so it is used for android development.
Java is very popular language due to its awesome features and performance. The community of Developers those have proficiency is really big. Thus android developers to choose java as there is already a good base of java programmers are available that can help in creating, improving android applications plus with many libraries and java tools makes developer life easy. Large java developer base enables to develop a lot of android apps fast so it is based on java.
Developers those do not use java have to deal with serious problems like memory leads and bad pointer usage. Sometimes these problems harm at the highest level like the crash of application or crash of OS. Android easily implement and fix common problems with other programming languages with the help of Java. These are some problems those never occur when you program with java. Java is machine independent and runs only in JVM space so it protects you from these problems.
Java is the best and the first language for native software development. That is really the only option for native applications, native applications are the heart of android.
Java’s important core features also motivated android developer is to use, these features include easy learning, platform-independent, secure, object-orientation.
Intent-Android application components can connect to other Android applications. This connection is based on a task description represented by an Intent object.
Intents are asynchronous messages which allow application components to request functionality from other Android components. Intents allow you to interact with components from the same applications as well as with components contributed by other applications. For example, an activity can start an external activity for taking a picture.
Intents are objects of the android.content.Intent type. Your code can send them to the Android system defining the components you are targeting. For example, via the startActivity() method you can define that the intent should be used to start an activity.
An intent can contain data via a Bundle. This data can be used by the receiving component.
In Android the reuse of other application components is a concept known as task. An application can access other Android components to achieve a task. For example, from a component of your application you can trigger another component in the Android system, which manages photos, even if this component is not part of your application. In this component you select a photo and return to your application to use the selected photo.
Start Activity Of Intent-To start an activity, use the method startActivity ofIntent. This method is defined on the Context object which Activity extends.
Intent Types- Intents Are Of Two Types Implicit , Explicit Intent
Implicit Intent-An implicit Intent
, like an explicit Intent
, is an instance of the Intent class. In addition to the parts of an Intent
you learned about in an earlier chapter (such as the Intent
data and extras), these fields are used by an implicit Intent
:
- The
Intent
action, which is the generic action the receivingActivity
should perform. The availableIntent
actions are defined as constants in the Intent class and begin with the wordACTION_
. A commonIntent
action isACTION_VIEW
, which you use when you have some information that anActivity
can show to the user, such as a photo to view in a gallery app, or an address to view in a map app. You can specify the action for anIntent
in theIntent
constructor, or with thesetAction()
method. - An
Intent
category, which provides additional information about the category of component that should handle theIntent
.Intent
categories are optional, and you can add more than one category to anIntent
.Intent
categories are also defined as constants in theIntent
class and begin with the wordCATEGORY_
. You can add categories to theIntent
with theaddCategory()
method. - The data type, which indicates the MIME type of data the
Activity
should operate on. Usually, the data type is inferred from the URI in theIntent
data field, but you can also explicitly define the data type with thesetType()
method.
We can also pass the information from one activity to another using explicit intent.
Here, we are going to see an example to call one activity from another activity
By Shrey Sharma
Wow, thank you so much❤️.... terribly waiting for the day when you guys start sharing coding as well🤩 All the very best to all of you🎉
ReplyDelete