Fragment

1:-How to work out when Fragment becomes visible in ViewPager?

Android Support Library (rev 11) finally has fixed issue of the user visible hint, now if you use fragments support library , then can use getUserVisibleHint() or override setUserVisibleHint() to capture the changes as described.

Here is one small problem with getUserVisibleHint(). This value is by default true.

boolean mUserVisibleHint = true;

So there could be an issue after you try and use it before setUserVisibleHint() was invoked. As a workaround you would possibly set value in onCreate method like this.

public void onCreate(@Nullable Bundle

savedInstanceState) { setUserVisibleHint(false);

2:-Can you name some Fragment subclasses?

ListFragment – Contains a ListView object by default DialogFragment – Displays a Dialog on top of its activity PreferenceFragment – Shows a hierarchy of Preference objects as a list.                                              WebViewFragment- Displays a Webview.

3:-How can a fragment communicate with an Activity?

To permit a fragment to speak up to its Activity, you’ll be able to define an interface within the Fragment class and implement it within the Activity. During its onAttach() lifecycle method  the Fragment captures the interface implementation

4:-What is the Fragment backstack?

A stack  that represents the order in which the Fragments are displayed and sorted is called Fragment backstack .

5:-What is the FragmentManager?

A FragmentManager is an object that-Retrieves fragments that exist in the activity Pops fragments off the backstack Registers a listener for changes to the backstack.

6:-When is the onAttach() method called?

The onAttach() method is called when the Fragment is attached to the Activity and can have access to its context object.

7:-How does the Fragment lifecycle relate to the Activity lifecycle?

 The Fragment lifecycle shares many of its callbacks with the Activity lifecycle. It includes additional callbacks like onAttach() and onActivityCreated() that signal to the Fragment the state of the corresponding Activity.

8:-Name the methods of the Fragment lifecycle.

  • onAttach()
  • onCreate()
  • onCreateView()
  • onActivityCreated()
  • onStart()
  • onResume()
  • onPause()
  • onStop()
  • onDestroyView()
  • onDestroy()
  • onDetach()

9:-What is the fragment lifecycle?

Similar to Activities, the Fragment lifecycle is a set of callbacks that allow the Fragment to know that a state has changed: that the system is creating, stopping, or resuming a Fragment.

10-When would you use Fragments instead of Views?

The main reason to use Fragments are for the lifecycle features and back stack.

11:-What are some benefits of using Fragments?

  • Reusability – Fragments can be reused across multiple activities
  • Supporting configuration changes – Fragments
  • can be rearranged when configuration change

12:-What is a Fragment?

 A Fragment reperesnts a behavior or a portion of user interface. You can add multiple fragments in a single activity to build a multipane UI and reuse a fragment in multiple activities

Service

1:-Why use a Service instead of a Thread?

Thread is useful when the app needs to perform work outside the main Thread, but only while the user is interacting with the application. A Service is useful for work that needs to be done independently of any Activity.

2:-Describe the Service lifecycle?

The Service lifecycle is a set of callbacks that allow the Service to know the state it is in. The Service lifecycle depends on whether the service is a started Service or a bound Service. Some important callbacks are:

  • onCreate()
  • onStartCommand()
  • onBind()
  • on Unbind() 
  • onDestroy()

3:-How do you stop a Service?

A Service can be stopped by calling stopService() or stopSelf().

4:-What is Started Service?

A started Service is started by another component (Activity, Broadcast receiver and Content provider) by calling startService(). it is run in background indefinitely even the component that started it also destroyed.

5:-What is a Bound Service?

Bound service is bound  to application component  by calling bindService(). A bound Service provide a client-server interface which  allows components to interact with the Service, send requests and receive results.

6:-What is a Background Service?

A background Service performs an operation that is not directly noticed by the user, such as updating a database.

7:-What is a Foreground Service?

In foreground service performed operation is noticable to the user. Foreground services must display a Notification. Foreground services continuesly running even when the user is not interacting with the app.

8:-What types of Services are there in the Android system?

  • Foreground
  • Background
  • Bound

8:-What is a Service?

A Service is an application component. Service use to perform long running operations in the background in which some visible to user and some invisible.

Gradle Questions Answers

1:-What is multidex?

The Android system is designed to handle apps that have less than 65536 methods. Multidex allows you to overcome that limitation by enabling it in the build.gradle file.

2:-What is ProGuard?

Proguard is a system that shrinks and obfuscates resources in order to reduce APK size and increase security.

3:-What is multiple manifest file merging?

Merging manifests is a way to provide different manifest configurations for different modules of the project, and have them merged into a single coherent configuration based on the build variant and flavor.

4:-What is build profiling?

Profiling is a flag set in the gradle build system that allows you to take a deeper look into the build process and find problem areas.

5:-What are flavor dimensions?

Dimensions are a way to combine configurations from multiple flavors.

6:-What are product flavors?

Product flavors allow an app to create different versions with different resources from the same project.

7:-What are build variants?

Build variants provides a way to have different versions of the app within the same project, such as debug, staging and release.

8:-What is the difference between the api and implementation configurations?

Implementation notifies the gradle system that this library should not be leaked to other modules at compile time. API allows a library to be leaked to other dependent modules.

9:-What are build dependencies?

They are a convenient way to include external libraries into an Android project.

10:-What is the application ID?

It is a flavor specific ID that allows the app to be distinguished from other apps on the playstore and on the end device.

11:-What is the module level build file?

The module level build file defines module specific configuration.

12:-What is the top level build file?

The top level build file specifies configuration relating to the project as a whole.

13:-What is a build.gradle file?

 A gradle configuration file that specifies build parameters for the project. It includes imported libraries, version configuration and flavor specific configuration among other things.

Permission Questions Answers

1:-What are permission groups?

They are groupings of permissions that allow the user to treat multiple permissions as a single one. Granting one permission in a group means granting all permissions in that group.

2:-What is the required=”flag” flag?

Indicates optional hardware requirements for the app, in order to support devices that may not have this feature.

3:-What is the difference between runtime requests and install time request?

Before Android 6.0 permissions were granted by the user when the app is installed on the playstore. After Android 6.0, each permission is requested when needed inside the app, and the user approves or rejects each permission individually.

4:-What types of permissions are there?

Normal permissions – The android system grants these automatically Dangerous permissions – Need user approval

5:-How does an app request permissions?

Using the flag in the Android manifest

6:-What are app permissions?

Permissions are requests made by the app to access sensitive user information. Depending on the feature, the system might grant the permission automatically or might prompt the user to approve the request.

Manifest Questions Answers

1:-What is the<uses features> tag?

Tag is the manifest that declares hardware and software features your app needs.

2:-What is the <uses permission>tag?

Tag in the manifest that requests permission to access sensitive user data.

3:-What are the main component tags?

  • Components of the app, which include all Activities, Services, BroadcastReceivers, and
  • Content Providers
  • Permissions that the app needs
  • Hardware and software features the app requires
  • The apps package name.

4:-What is the android manifest file?

The manifest file is an xml configuration file that describes essential information about the project to the system and to the playstore.

Read

ANDROID DEVELOPMENT INTERVIEW QUESTIONS AND ANSWERS FOR FRESHERS #1

You may also like...

0 Comments

No Comment.