Flutter complete interview questions with answers

 Flutter Questions and Answers

1.What is the difference between a StatelessWidget and a StatefulWidget in Flutter?

Stateless Widget A stateless widget can not change their state during the runtime of an app which means it can not redraw its self while the app is running. Stateless widgets are immutable.

Stateful Widget A stateful widget can redraw itself multiple times, while the app is running which means its state is mutable. For example, when a button is pressed, the state of the widget is changed

2.Explain the Stateful Widget Lifecycle?

The lifecycle has the following simplified steps: createState() mounted == true initState() didChangeDependencies() build() didUpdateWidget() setState() deactivate() dispose() mounted == false

life cycle


3.What is Flutter tree shaking (flutter web)?

When compiling a Flutter web application, the JavaScript bundle is generated by the dart2js compiler. A release build has the highest level of optimization, which includes tree shaking your code. Tree shaking is the process of eliminating dead code, by only including code that is guaranteed to be executed. This means that you do not need to worry about the size of your app’s included libraries because unused classes or functions are excluded from the compiled JavaScript bundle

4.What is a Spacer widget?

Spacer manages the empty space between the widgets with flex container. Evenly with the Row and Column MainAxis alignment we can manage the space as well

5.What is the difference between hot restart and hot reload?

What is Hot Reload in Flutter:

Flutter hot reload features works with combination of Small r key on command prompt or Terminal. Hot reload feature quickly compile the newly added code in our file and sent the code to Dart Virtual Machine. After done updating the Code Dart Virtual Machine update the app UI with widgets. Hot Reload takes less time then Hot restart. There is also a draw back in Hot Reload, If you are using States in your application then Hot Reload preservers the States so they will not update on Hot Reload our set to their default values

What is Hot Restart in Flutter:

Hot restart is much different than hot reload. In Hot restart it destroys the preserves State value and set them to their default. So if you are using States value in your application then After every hot restart the developer gets fully compiled application and all the states will set to their defaults. The app widget tree is completely rebuilt with new typed code. Hot Restart takes much higher time than Hot reload

6.What is an InheritedWidget?

7.Why is the build() method on State and not StatefulWidget?

stateful_build

8.What is a pubspec file in Dart?

The pubspec file manages the assets and dependencies for a Flutter app.

9.How is Flutter native?

Flutter uses only the canvas of the native platform and draws the UI and all the components from scratch. All the UI elements look the same as native ones. This mainly reduces the burden of time for converting through some language to the native one and speeds up the UI rendering time. As a result, the UI performance is remarkably high

10.What is a Navigator and what are Routes in Flutter?

Navigation and routing are some of the core concepts of all mobile application, which allows the user to move between different pages. We know that every mobile application contains several screens for displaying different types of information. For example, an app can have a screen that contains various products. When the user taps on that product, immediately it will display detailed information about that product

11.What is a PageRoute?

Allow us to add animation transaction to the route https://github.com/divyanshub024/Flutter-route-transition

12.Explain asyncawait and Future?

Async means that this function is asynchronous and you might need to wait a bit to get its result. Await literally means - wait here until this function is finished and you will get its return value. Future is a type that ‘comes from the future’ and returns value from your asynchronous function. It can complete with success(.then) or with an error(.catchError)

13.how can you update a listview dynamically?

By using setState to update the listview item source and rebuild the UI

14.What is a Stream?

A stream is like a pipe, you put a value on the one end and if there’s a listener on the other end that listener will receive that value. A Stream can have multiple listeners and all of those listeners will receive the same value when it’s put in the pipeline. The way you put values on a stream is by using a StreamController

15.What are keys in Flutter and when should you use it?

You don't need to use Keys most of the time, the framework handles it for you and uses them internally to differentiate between widgets. There are a few cases where you may need to use them though.

A common case is if you need to differentiate between widgets by their keys, ObjectKey and ValueKey can be useful for defining how the widgets are differentiated

Another example is that if you have a child you want to access from a parent, you can make a GlobalKey in the parent and pass it to the child's constructor. Then you can do globalKey.state to get the child's state (say for example in a button press callback). Note that this shouldn't be used excessively as there are often better ways to get around it

16.What are GlobalKeys?

GlobalKeys have two uses: they allow widgets to change parents anywhere in your app without losing state, or they can be used to access information about another widget in a completely different part of the widget tree. An example of the first scenario might if you wanted to show the same widget on two different screens, but holding all the same state, you’d want to use a GlobalKey

17.When should you use mainAxisAlignment and crossAxisAlignment?

mainAxisAlignment


18.When can you use double.INFINITY?

When you want the widget to be big as the parent widget allow

19.What is TickerTween and AnimationController?

ticker

Animation Sequences To achieve sequence animation we’ll introduce a new Widget that also helps with reducing animation code called AnimatedBuilder which allows you to rebuild your widget through a builder function every time a new animation value is calculated

20.What is ephemeral state?

ephemeral

21.What is an AspectRatio widget used for?

AspectRatio Widget tries to find the best size to maintain aspect ration while respecting it’s layout constraints. The AspectRatio Widget can be used to adjust the aspect ratio of widgets in your app

22.How would you access StatefulWidget properties from its State?

Using the widget property

23.Mention two or more operations that would require you to use or turn a Future

1. Calling api using http
2. Getting result from geolocator package 
3. With FutureBuilder widget 

24.What is the purpose of a SafeArea?

SafeArea is basically a glorified Padding widget. If you wrap another widget with SafeArea, it adds any necessary padding needed to keep your widget from being blocked by the system status bar, notches, holes, rounded corners and other "creative" features by manufactures


25.When to use a mainAxisSize?

When you use MainAxisSize on your Column or Row, they will determine the size of the Column or Row along the main axis, i.e, height for Column and width for Row

26.SizedBox VS Container?

sized

sized2

27.List the Visibility widgets in flutter and the differences?

1. Visibility
2. Opacity
3. Offstage

28.Can we use Color and Decoration property simultaneously in the Container?

No

The color property is a shorthand for creating a BoxDecoration with a color field. If you are adding a box decoration, simply place the color on the BoxDecoration.


29.Inorder for the CrossAxisAlignment.baseline to work what is another property that we need to set?

crossAxisAlignment: CrossAxisAlignment.baseline textBaseline: TextBaseline.ideographic,


30.when should we use a resizeToAvoidBottomInset?

If true the body and the scaffold's floating widgets should size themselves to avoid the onscreen keyboard whose height is defined by the ambient MediaQuery's MediaQueryData.viewInsets bottom property.

For example, if there is an onscreen keyboard displayed above the scaffold, the body can be resized to avoid overlapping the keyboard, which prevents widgets inside the body from being obscured by the keyboard

With resizeToAvoidBottomInset https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/316760/7da984e6-ec32-7989-174c-0e104e4c5557.gif

without resizeToAvoidBottomInset https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/316760/0c933d45-82a2-4401-836c-d1c6f5abc2db.gif


31.What is the difference between as,show and hide in an import statement?

as


32.What is the importance of a TextEditingController?

Whenever the user modifies a text field with an associated TextEditingController, the text field updates value and the controller notifies its listeners. Listeners can then read the text and selection properties to learn what the user has typed or how the selection has been updated


33.Why do we use a Reverse property in a Listview?

List animals = ['cat', 'dog', 'duck']; List reversedAnimals = animals.reversed.toList();


34.Difference between a Modal and Persistent BottomSheet with an example?


35.How is an Inherited Widget different from a Provider?

Provider basically takes the logic of InheritedWidgets, but reduce the boilerplate to the strict minimum


36.What is an UnmodifiableListView?

Cannot change the list items by adding or removing

37.Difference between these operators ?? and ?.

?? expr1 ?? expr2 If expr1 is non-null, returns its value; otherwise, evaluates and returns the value of expr2.

?. Like . but the leftmost operand can be null; example: foo?.bar selects property bar from expression foo unless foo is null (in which case the value of foo?.bar is null)

38.What is the purpose of ModalRoute.of()?

ModalRoute.of() method. This method returns the current route with the arguments

final args = ModalRoute.of(context).settings.arguments;


39.Difference between a Navigator.pushNamed and Navigator.pushReplacementNamed?

pushNamed

40.Difference between a Single Instance and Scoped Instance ?

41.Difference between getDocuments() vs snapshots()?

getDocuments


42.What is a vsync?

Vsync basically keeps the track of screen, so that Flutter does not renders the animation when the screen is not being displayed


43.When does the animation reach completed or dismissed status?

animations that progress from 0.0 to 1.0 will be dismissed when their value is 0.0. An animation might then run forward (from 0.0 to 1.0) or perhaps in reverse (from 1.0 to 0.0). Eventually, if the animation reaches the end of its range (1.0), the animation reaches the completed status.


44.Difference between AnimationController and Animation?

AnimationController is for how long the animation would be and how to control from time, upper and lower boundary, how to control data with time, length, sequence, etc. while AnimationTween is for the range of animation with time, colour, range, sequence, etc as long the animation would be while


45.When to use a SingleTickerProviderStateMixin and TickerProviderStateMixin?


46.Define a TweenAnimation ?

Short for in-betweening. In a tween animation, the beginning and ending points are defined, as well as a timeline, and a curve that defines the timing and speed of the transition. The framework calculates how to transition from the beginning point to the end point


47.State the importance of a Ticker ?

Ticker is the refresh rate of our animations. This is what we want to pause when our clock is hidden.

A bonus for using Ticker is that this allows the dev-tool to “slow” our animation. If we use “Slow animations”, then our clock is slowed by 50%. This is a good sign, as it means it will be a lot easier to test our clock!


48.Why do we need a mixins ?

Mixins are very helpful when we want to share a behavior across multiple classes that don’t share the same class hierarchy, or when it doesn’t make sense to implement such a behavior in a superclass


49.When do you use the WidgetsBindingObserver?

To check when the system puts the app in the background or returns the app to the foreground


50.Why does the first flutter app take a very long developing time?

When you are going to build the Flutter app for the first time, it takes a very long time than usual because Flutter builds a device-specific IPA or APK file. In this process, the Xcode and Gradle are used to build a file, which usually takes a long time


51.Define what is an App State?

The App State is also called an application state or shared state. The app state can be distributed across multiple areas of your app and the same is maintained with user sessions.

Following are the examples of App State:

Login info User preferences The shopping cart of an e-commerce application


52.What are the two types of Streams available in Flutter?

Single subscription streams:

It is a popular and common type of stream. It consists of a series of events that are parts of a large whole. Here all events have to be delivered in a defined order without even missing a single event. It is a type of stream that you get when you get a web request or receive a file. This stream can only be listed once. Listing it, again and again, means missing initial values and overall stream makes no sense at all. When the listing starts in this stream the data gets fetched and provided in chunks.

Broadcast streams:

This stream is meant for the individual messages that can be handled one at a time. These types of streams are commonly used for mouse events in a browser. You can list this type of stream at any time. Multiple listeners can listen at a time and also you have a chance to listen after the cancellation of the previous subscription


53.What do you know about Dart Isolates?

To gain concurrency Dart makes use of the Isolates method which works on its own without sharing memory but uses passing or message communication.


54.What is a Flutter inspector?

Flutter inspector is a tool that helps in visualizing and exploring the widget trees. It helps in understanding the present layout and diagnoses various layout issues


55.Stream vs Future?

The difference is that Futures are about one-shot request/response (I ask, there is a delay, I get a notification that my Future is ready to collect, and I'm done!) whereas Streams are a continuous series of responses to a single request (I ask, there is a delay, then I keep getting responses until the stream dries up or I decide to close it and walk away)


56.How to compare two dates that are constructed differently in Dart?

date


57.What's the difference between async and async* in Dart?

async


58.Debug vs Profile mode?

In debug mode, the app is set up for debugging on the physical device, emulator, or simulator.

Debug

Assertions are enabled. Service extensions are enabled. Compilation is optimized for fast development and run cycles (but not for execution speed, binary size, or deployment). Debugging is enabled, and tools supporting source level debugging (such as DevTools) can connect to the process.

Profile In profile mode, some debugging ability is maintained—enough to profile your app’s performance. Profile mode is disabled on the emulator and simulator, because their behavior is not representative of real performance. On mobile, profile mode is similar to release mode, with the following differences:

Some service extensions, such as the one that enables the performance overlay, are enabled. Tracing is enabled, and tools supporting source-level debugging (such as DevTools) can connect to the process.


59.How to convert a List into a Map in Dart?

list


60.What does non-nullable by default mean?

no_null


61.Expanded vs Flexible?

flex1

flex2


62.Why is exit(0) not preferred for closing an app?

exit0


63.What is the difference between main function and the runApp() function in Flutter?

In Dart, main() acts as the entry point for the program whereas runApp() attaches the given widget to the screen.


64.What is Dart and why does Flutter use it?

Dart is AOT (Ahead Of Time) compiled to fast, predictable, native code, which allows almost all of Flutter to be written in Dart. This not only makes Flutter fast, virtually everything (including all the widgets) can be customized.

Dart can also be JIT (Just In Time) compiled for exceptionally fast development cycles and game-changing workflow (including Flutter’s popular sub-second stateful hot reload).

Dart makes it easier to create smooth animations and transitions that run at 60fps. Dart can do object allocation and garbage collection without locks. And like JavaScript, Dart avoids preemptive scheduling and shared memory (and thus locks). Because Flutter apps are compiled to native code, they do not require a slow bridge between realms (e.g., JavaScript to native). They also start up much faster.

Dart allows Flutter to avoid the need for a separate declarative layout language like JSX or XML, or separate visual interface builders, because Dart’s declarative, programmatic layout is easy to read and visualize. And with all the layout in one language and in one place, it is easy for Flutter to provide advanced tooling that makes layout a snap.

Developers have found that Dart is particularly easy to learn because it has features that are familiar to users of both static and dynamic languages


65.Where are the layout files? Why doesn’t Flutter have layout files?

In the Android framework, we separate an activity into layout and code. Because of this, we need to get references to views to work on them in Java. (Of course Kotlin lets you avoid that.) The layout file itself would be written in XML and consist of Views and ViewGroups.

Flutter uses a completely new approach where instead of Views, you use widgets. A View in Android was mostly an element of the layout, but in Flutter, a Widget is pretty much everything. Everything from a button to a layout structure is a widget. The advantage here is in customisability. Imagine a button in Android. It has attributes like text which lets you add text to the button. But a button in Flutter does not take a title as a string, but another widget. Meaning inside a button you can have text, an image, an icon and pretty much anything you can imagine without breaking layout constraints. This also lets you make customised widgets pretty easily whereas in Android making customised views is a rather difficult thing to do


66.What is the difference between final and const in Flutter?

final means single-assignment: A final variable or field must have an initializer. Once assigned a value, a final variable's value cannot be changed. final modifies variables.

const has a meaning that's a bit more complex and subtle in Dart. const modifies values. You can use it when creating collections, like const [1, 2, 3], and when constructing objects (instead of new) like const Point(2, 3). Here, const means that the object's entire deep state can be determined entirely at compile time and that the object will be frozen and completely immutable.

Const objects have a couple of interesting properties and restrictions:

They must be created from data that can be calculated at compile time. A const object does not have access to anything you would need to calculate at runtime. 1 + 2 is a valid const expression, but new DateTime.now() is not.

They are deeply, transitively immutable. If you have a final field containing a collection, that collection can still be mutable. If you have a const collection, everything in it must also be const, recursively.

They are canonicalized. This is sort of like string interning: for any given const value, a single const object will be created and re-used no matter how many times the const expression(s) are evaluated.

50 Android Interview Questions & Answers (2021 Update)

 1) What is Android?

It is an open-sourced operating system that is used primarily on mobile devices, such as cell phones and tablets. It is a Linux kernel-based system that’s been equipped with rich components that allows developers to create and run apps that can perform both basic and advanced functions.

2) What Is the Google Android SDK?

The Google Android SDK is a toolset that developers need in order to write apps on Android enabled devices. It contains a graphical interface that emulates an Android driven handheld environment, allowing them to test and debug their codes.

3) What is the Android Architecture?

Android Architecture is made up of 4 key components:

  • Linux Kernel
  • Libraries
  • Android Framework
  • Android Applications

4) Describe the Android Framework.

The Android Framework is an important aspect of the Android Architecture. Here you can find all the classes and methods that developers would need in order to write applications on the Android environment.

5) What is AAPT?

AAPT is short for Android Asset Packaging Tool. This tool provides developers with the ability to deal with zip-compatible archives, which includes creating, extracting as well as viewing its contents.

6) What is the importance of having an emulator within the Android environment?

The emulator lets developers “play” around an interface that acts as if it were an actual mobile device. They can write and test codes, and even debug. Emulators are a safe place for testing codes especially if it is in the early design phase.


7) What is the use of an activityCreator?

An activityCreator is the first step towards the creation of a new Android project. It is made up of a shell script that will be used to create new file system structure necessary for writing codes within the Android IDE.


8 ) Describe Activities.

Activities are what you refer to as the window to a user interface. Just as you create windows in order to display output or to ask for an input in the form of dialog boxes, activities play the same role, though it may not always be in the form of a user interface.


9) What are Intents?

Intents displays notification messages to the user from within the Android enabled device. It can be used to alert the user of a particular state that occurred. Users can be made to respond to intents.


10) Differentiate Activities from Services.

Activities can be closed, or terminated anytime the user wishes. On the other hand, services are designed to run behind the scenes, and can act independently. Most services run continuously, regardless of whether there are certain or no activities being executed.


11) What items are important in every Android project?

These are the essential items that are present each time an Android project is created:

  • AndroidManifest.xml
  • build.xml
  • bin/
  • src/
  • res/
  • assets/

12) What is the importance of XML-based layouts?

The use of XML-based layouts provides a consistent and somewhat standard means of setting GUI definition format. In common practice, layout details are placed in XML files while other items are placed in source files.


13) What are containers?

Containers, as the name itself implies, holds objects and widgets together, depending on which specific items are needed and in what particular arrangement that is wanted. Containers may hold labels, fields, buttons, or even child containers, as examples.


14) What is Orientation?

Orientation, which can be set using setOrientation(), dictates if the LinearLayout is represented as a row or as a column. Values are set as either HORIZONTAL or VERTICAL.


15) What is the importance of Android in the mobile market?

Developers can write and register apps that will specifically run under the Android environment. This means that every mobile device that is Android enabled will be able to support and run these apps. With the growing popularity of Android mobile devices, developers can take advantage of this trend by creating and uploading their apps on the Android Market for distribution to anyone who wants to download it.


16) What do you think are some disadvantages of Android?

Given that Android is an open-source platform, and the fact that different Android operating systems have been released on different mobile devices, there’s no clear cut policy to how applications can adapt with various OS versions and upgrades. One app that runs on this particular version of Android OS may or may not run on another version. Another disadvantage is that since mobile devices such as phones and tabs come in different sizes and forms, it poses a challenge for developers to create apps that can adjust correctly to the right screen size and other varying features and specs.


17) What is adb?

Adb is short for Android Debug Bridge. It allows developers the power to execute remote shell commands. Its basic function is to allow and control communication towards and from the emulator port.


18) What are the four essential states of an activity?

  • Active – if the activity is at the foreground
  • Paused – if the activity is at the background and still visible
  • Stopped – if the activity is not visible and therefore is hidden or obscured by another activity
  • Destroyed – when the activity process is killed or completed terminated

19) What is ANR?

ANR is short for Application Not Responding. This is actually a dialog that appears to the user whenever an application have been unresponsive for a long period of time.


20) Which elements can occur only once and must be present?

Among the different elements, the “and” elements must be present and can occur only once. The rest are optional, which can occur as many times as needed.


21) How are escape characters used as attribute?

Escape characters are preceded by double backslashes. For example, a newline character is created using ‘\\n’


22) What is the importance of settings permissions in app development?

Permissions allow certain restrictions to be imposed primarily to protect data and code. Without these, codes could be compromised, resulting to defects in functionality.


23) What is the function of an intent filter?

Because every component needs to indicate which intents they can respond to, intent filters are used to filter out intents that these components are willing to receive. One or more intent filters are possible, depending on the services and activities that is going to make use of it.


24) Enumerate the three key loops when monitoring an activity

  • Entire lifetime – activity happens between onCreate and onDestroy
  • Visible lifetime – activity happens between onStart and onStop
  • Foreground lifetime – activity happens between onResume and onPause

25) When is the onStop() method invoked?

A call to onStop method happens when an activity is no longer visible to the user, either because another activity has taken over or if in front of that activity.


26) Is there a case wherein other qualifiers in multiple resources take precedence over locale?

Yes, there are actually instances wherein some qualifiers can take precedence over locale. There are two known exceptions, which are the MCC (mobile country code) and MNC (mobile network code) qualifiers.


27) What are the different states wherein a process is based?

There are 4 possible states:

  • foreground activity
  • visible activity
  • background activity
  • empty process

28) How can the ANR be prevented?

One technique that prevents the Android system from concluding a code that has been responsive for a long period of time is to create a child thread. Within the child thread, most of the actual workings of the codes can be placed, so that the main thread runs with minimal periods of unresponsive times.


29) What role does Dalvik play in Android development?

Dalvik serves as a virtual machine, and it is where every Android application runs. Through Dalvik, a device is able to execute multiple virtual machines efficiently through better memory management.


30) What is the AndroidManifest.xml?

This file is essential in every application. It is declared in the root directory and contains information about the application that the Android system must know before the codes can be executed.


31) What is the proper way of setting up an Android-powered device for app development?

The following are steps to be followed prior to actual application development in an Android-powered device:

-Declare your application as “debuggable” in your Android Manifest.
-Turn on “USB Debugging” on your device.
-Set up your system to detect your device.


32) Enumerate the steps in creating a bounded service through AIDL.

1. create the .aidl file, which defines the programming interface
2. implement the interface, which involves extending the inner abstract Stub class as well as implanting its methods.
3. expose the interface, which involves implementing the service to the clients.


33) What is the importance of Default Resources?

When default resources, which contain default strings and files, are not present, an error will occur and the app will not run. Resources are placed in specially named subdirectories under the project res/ directory.


34) When dealing with multiple resources, which one takes precedence?

Assuming that all of these multiple resources are able to match the configuration of a device, the ‘locale’ qualifier almost always takes the highest precedence over the others.


35) When does ANR occur?

The ANR dialog is displayed to the user based on two possible conditions. One is when there is no response to an input event within 5 seconds, and the other is when a broadcast receiver is not done executing within 10 seconds.


36) What is AIDL?

AIDL, or Android Interface Definition Language, handles the interface requirements between a client and a service so both can communicate at the same level through interprocess communication or IPC. This process involves breaking down objects into primitives that Android can understand. This part is required simply because a process cannot access the memory of the other process.


37) What data types are supported by AIDL?

AIDL has support for the following data types:

-string
-charSequence
-List
-Map
-all native Java data types like int,long, char and Boolean


38) What is a Fragment?

A fragment is a part or portion of an activity. It is modular in a sense that you can move around or combine with other fragments in a single activity. Fragments are also reusable.


39) What is a visible activity?

A visible activity is one that sits behind a foreground dialog. It is actually visible to the user, but not necessarily being in the foreground itself.


40) When is the best time to kill a foreground activity?

The foreground activity, being the most important among the other states, is only killed or terminated as a last resort, especially if it is already consuming too much memory. When a memory paging state has been reach by a foreground activity, then it is killed so that the user interface can retain its responsiveness to the user.


41) Is it possible to use or add a fragment without using a user interface?

Yes, it is possible to do that, such as when you want to create a background behavior for a particular activity. You can do this by using add(Fragment,string) method to add a fragment from the activity.


42) How do you remove icons and widgets from the main screen of the Android device?

To remove an icon or shortcut, press and hold that icon. You then drag it downwards to the lower part of the screen where a remove button appears.


43) What are the core components under the Android application architecture?

There are 5 key components under the Android application architecture:

– services
– intent
– resource externalization
– notifications
– content providers


44) What composes a typical Android application project?

A project under Android development, upon compilation, becomes an .apk file. This apk file format is actually made up of the AndroidManifest.xml file, application code, resource files, and other related files.


45) What is a Sticky Intent?

A Sticky Intent is a broadcast from sendStickyBroadcast() method such that the intent floats around even after the broadcast, allowing others to collect data from it.


46) Do all mobile phones support the latest Android operating system?

Some Android-powered phone allows you to upgrade to the higher Android operating system version. However, not all upgrades would allow you to get the latest version. It depends largely on the capability and specs of the phone, whether it can support the newer features available under the latest Android version.


47) What is portable wi-fi hotspot?

Portable Wi-Fi Hotspot allows you to share your mobile internet connection to other wireless device. For example, using your Android-powered phone as a Wi-Fi Hotspot, you can use your laptop to connect to the Internet using that access point.


48) What is an action?

In Android development, an action is what the intent sender wants to do or expected to get as a response. Most application functionality is based on the intended action.


49) What is the difference between a regular bitmap and a nine-patch image?

In general, a Nine-patch image allows resizing that can be used as background or other image size requirements for the target device. The Nine-patch refers to the way you can resize the image: 4 corners that are unscaled, 4 edges that are scaled in 1 axis, and the middle one that can be scaled into both axes.


50) What language is supported by Android for application development?

The main language supported is Java programming language. Java is the most popular language for app development, which makes it ideal even for new Android developers to quickly learn to create and deploy applications in the Android environment.

ANDROID INTERVIEW QUESTIONS

 

1. What is shared preferences in android?

Shared Preferences is the way in which one can store and retrieve small amounts of primitive data as key/value pairs to a file on the device storage such as String, int, float, Boolean that make up your preferences in an XML file inside the app on the device storage.

2. What are the key components in android architecture?

  • Linux kernel.
  • Libraries.
  • Android Libraries.
  • Android Runtime.
  • Application Framework.
  • Applications

3. What are the different storages available in android?

There are four type of storage that android are:
  • Internal file storage: Store app-private files on the device file system.
  • External file storage: Store files on the shared external file system.
  • Shared preferences: Store private primitive data in key-value pairs.
  • Databases: Store structured data in a private database.

4. What is a Sticky Intent in android?

Sticky Intent is also a type of the Intent which allows communication between a function and a service sendStickyBroadcast(), performs a sendBroadcast known as sticky, the Intent you are sending stays around after the broadcast is complete.

5. How is the use of web view in Android?

Android WebView is used to display web page in android. The web page can be loaded from same application or URL. It is used to display online content in android activity. The loadUrl() and loadData() methods of Android WebView class are used to the load and display web page.

6. Why can't you run java byte code on Android?

Android uses Dalvik virtual machine instead of Java VM. To run a Java Bytecode you need Java Virtual Machine. Java in computers and Android uses a separate environment to run their code.

7. What are application Widgets in android?

App Widgets are miniature application views that can be embedded in other applications and the receive periodic updates. These views are referred to as Widgets in the user interface, and you can publish one with an App Widget provider.

8. Name the different data storage options available on the Android platform.

There are four type of storage are:

  • Internal file storage: Store app-private files on the device file system.
  • External file storage: Store files on the shared external file system.
  • Shared preferences: Store private primitive data in key-value pairs.
  • Databases: Store structured data in a private database.

9. What are the different data types supported by AIDL?

The different data types supported by AIDL are:

  • All primitive types in the Java programming language.
  • Arrays of primitive types such as int[]
  • String.
  • CharSequence.
  • List.
  • Map.

10. Explain the term ANR in Android

The term ANR in Android Stands for "Application Not Responding.

11. What is the importance of setting up permission in Android application development?

Permission allows certain restrictions to be imposed primarily to protect the data and code. Without this, codes could be compromised, resulting in defects in the actual function.

12. State the components which are necessary for a New Android Project

There are four different types of app components are:

  • Activities.
  • Services.
  • Broadcast receivers.
  • Content providers.

13. Explain different launch modes in Android

The different launch modes in Android are:

  • standard.
  • singleTop.
  • singleTask.
  • singleInstance.
  • Intent Flags.

14. What is the AndroidManifest.xml file and why do you need this?

xml file with precisely that name at the root of the project source set. The manifest file describes essential information about your app to the Android build tools, the Android operating system, and Google Play. The Android build tools use this to determine the location of the code entities when building your project.

How to extract filename from Uri?

Now, we can extract filename with and without extension :) You will convert your bitmap to uri and get the real path of your file. Now w...