MAD question bank Flashcards

1
Q

How do you publish android applications in the market? Explain

A

Android application publishing is a process that makes your Android applications available to users. Infect, publishing is the last phase of the Android application development process.

Once you developed and fully tested your Android Application, you can start selling or distributing free using Google Play (A famous Android marketplace). You can also release your applications by sending them directly to users or by letting users download them from your own website.

You can check a detailed publishing process at Android official website, but this tutorial will take you through simple steps to launch your application on Google Play. Here is a simplified check list which will help you in launching your Android application −

  1. Regression Testing
    Before you publish your application, you need to make sure that its meeting the basic quality expectations for all Android apps, on all of the devices that you are targeting. So perform all the required testing on different devices including phone and tablets.
    2 Application Rating
    When you will publish your application at Google Play, you will have to specify a content rating for your app, which informs Google Play users of its maturity level. Currently available ratings are (a) Everyone (b) Low maturity (c) Medium maturity (d) High maturity.
    3 Targeted Regions
    Google Play lets you control what countries and territories where your application will be sold. Accordingly you must take care of setting up time zone, localization or any other specific requirement as per the targeted region.
    4 Application Size
    Currently, the maximum size for an APK published on Google Play is 50 MB. If your app exceeds that size, or if you want to offer a secondary download, you can use APK Expansion Files, which Google Play will host for free on its server infrastructure and automatically handle the download to devices.
    5 SDK and Screen Compatibility
    It is important to make sure that your app is designed to run properly on the Android platform versions and device screen sizes that you want to target.
    6 Application Pricing
    Deciding whether you app will be free or paid is important because, on Google Play, free app’s must remain free. If you want to sell your application then you will have to specify its price in different currencies.
    7 Promotional Content
    It is a good marketing practice to supply a variety of high-quality graphic assets to showcase your app or brand. After you publish, these appear on your product details page, in store listings and search results, and elsewhere.
    8 Build and Upload release-ready APK
    The release-ready APK is what you you will upload to the Developer Console and distribute to users. You can check complete detail on how to create a release-ready version of your app: Preparing for Release.
    9 Finalize Application Detail
    Google Play gives you a variety of ways to promote your app and engage with users on your product details page, from colourful graphics, screen shots, and videos to localized descriptions, release details, and links to your other apps. So you can decorate your application page and provide as much as clear crisp detail you can provide.

Before exporting the apps, you must some of tools

Dx tools(Dalvik executable tools ): It going to convert .class file to .dex file. it has useful for memory optimization and reduce the boot-up speed time

AAPT(Android assistance packaging tool):it has useful to convert .Dex file to.Apk

APK(Android packaging kit): The final stage of deployment process is called as .apk.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q
  1. Discuss the important characteristics of Mobile Applications.
A
  1. Simplicity for the End-User
    Convenient user interface and logical navigation are the foundation for a great UX. This simple characteristic makes an app rank the best among alternative digital products.
  2. Both iOS and Android Must Be Covered
  3. High Performance
    Remember the moment when your app is launched. Since that time, your software product should not make its users wait for something to be loaded. You should make sure that your app works fast, and if it does not — you should pay particular attention to it. Keep up with the continuous mobile app optimization to make all the screens and in-app processes loaded in a speedy manner. It is key for mobile app high performance.
  4. Security
    This feature is important for mobile apps across various industries, however, the financial and healthcare areas should be particularly emphasized here. Mobile app security means the user data are well-protected at a legal level. It is one of the critical requirements of a successive mobile app.
  5. Regular Updates
    The truly excellent software product needs a continuous process of improvements and updates. It promises the lasting popularity of a mobile app. Maintain your server and make sure that your content is always up-to-date. Regularly update an app and enrich it with new features.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q
  1. Explain about saving data to internal and external storage in Android Environment.
A
  1. Storage on the Inside
    When you install an app on your phone, the Android operating system will give you some form of secret internal storage where the app can store its private data. No other application has access to this information. When you uninstall an application, all of the data associated with it is also removed.

To save a file to the internal storage, you must first obtain it from the internal directory. You can do this by calling the getFilesDir() or getCacheDir() methods. The getFilesDir() method returns the absolute path to the directory where files are created on the filesystem. getCacheDir() returns the absolute path to the filesystem’s application-specific cache directory.

When Should Internal Storage Be Used?

The internal storage can be used when you need some confidential data for your application. Another thing to keep in mind is that if your app is storing data that may be utilized by other apps, you should avoid using internal storage since when you remove the app, all of your data will be gone, and other apps will never have access to that data. For instance, if your app is downloading a pdf or storing an image or video that might be used by other apps, you shouldn’t use internal storage.

  1. External Hard Drives
    Most Android devices have relatively low internal storage. As a result, we keep our data on an external storage device. These storage units are accessible to everyone, which means they can be accessed by all of your device’s applications. You can also access the storage by connecting your mobile device to a computer. You must obtain the READ EXTERNAL STORAGE permission from the user in order to gain access to the external storage. As a result, any application with this permission has access to your app’s data.

When is it appropriate to use external storage?

You can use external storage if the data that your application stores can be used by other applications. Additionally, if the file stored by your application is huge, such as a video, you can save it to external storage. You can use external storage to keep the data even after uninstalling the application.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q
  1. Write short notes on Kotlin and Object box.
A

Kotlin is a new open source programming language like Java, JavaScript, etc. It is a high level strongly statically typed language that combines functional and technical part in a same place. Currently, Kotlin targets Java and JavaScript. It runs on JVM.

Kotlin is influenced by other programming languages such as Java, Scala, Groovy, Gosu, etc. The syntax of Kotlin may not be exactly similar to JAVA, however, internally Kotlin is reliant on the existing Java Class library to produce wonderful results for the programmers. Kotlin provides interoperability, code safety, and clarity to the developers around the world.

ObjectBox is an Android database designed for Edge Computing and Offline First experiences.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q
  1. How Performance of an Android app can be judged? Discuss memory management in Android application development.
A

In this post, we’ll look at how to monitor app performance metrics to discover areas where the app uses resources inefficiently, such as CPU, network, memory, and device battery. The Android Profiler tools provide real-time statistics to understand how the app uses device resources. Several profiling tools are available in Android Studio to aid in the detection and visualization of possible issues:

CPU profiler: This tool helps in the identification of runtime performance issues.
Memory profiler: This tool aids in the tracking of memory allocations.
Network profiler: This tool measures network traffic utilization.
Energy profiler: This tool monitors energy consumption.

The Android Runtime (ART) and Dalvik virtual machine use paging and memory-mapping (mmapping) to manage memory. This means that any memory an app modifies—whether by allocating new objects or touching mmapped pages—remains resident in RAM and cannot be paged out. The only way to release memory from an app is to release object references that the app holds, making the memory available to the garbage collector. That is with one exception: any files mmapped in without modification, such as code, can be paged out of RAM if the system wants to use that memory elsewhere.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q
  1. Explain about Design standards of the User Interface (UI).
A

Visibility of system status.
Users should always be informed of system operations with easy to understand and highly visible status displayed on the screen within a reasonable amount of time.

Match between system and the real world.
Designers should endeavor to mirror the language and concepts users would find in the real world based on who their target users are. Presenting information in logical order and piggybacking on user’s expectations derived from their real-world experiences will reduce cognitive strain and make systems easier to use.

User control and freedom.
Offer users a digital space where backward steps are possible, including undoing and redoing previous actions.

Consistency and standards.
Interface designers should ensure that both the graphic elements and terminology are maintained across similar platforms. For example, an icon that represents one category or concept should not represent a different concept when used on a different screen.

Error prevention.
Whenever possible, design systems so that potential errors are kept to a minimum. Users do not like being called upon to detect and remedy problems, which may on occasion be beyond their level of expertise. Eliminating or flagging actions that may result in errors are two possible means of achieving error prevention.

Recognition rather than recall.
Minimize cognitive load by maintaining task-relevant information within the display while users explore the interface. Human attention is limited and we are only capable of maintaining around five items in our short-term memory at one time. Due to the limitations of short-term memory, designers should ensure users can simply employ recognition instead of recalling information across parts of the dialogue. Recognizing something is always easier than recall because recognition involves perceiving cues that help us reach into our vast memory and allowing relevant information to surface. For example, we often find the format of multiple choice questions easier than short answer questions on a test because it only requires us to recognize the answer rather than recall it from our memory.
Flexibility and efficiency of use. With increased use comes the demand for less interactions that allow faster navigation. This can be achieved by using abbreviations, function keys, hidden commands and macro facilities. Users should be able to customize or tailor the interface to suit their needs so that frequent actions can be achieved through more convenient means.

Aesthetic and minimalist design.
Keep clutter to a minimum. All unnecessary information competes for the user’s limited attentional resources, which could inhibit user’s memory retrieval of relevant information. Therefore, the display must be reduced to only the necessary components for the current tasks, whilst providing clearly visible and unambiguous means of navigating to other content.
Help users recognize, diagnose and recover from errors. Designers should assume users are unable to understand technical terminology, therefore, error messages should almost always be expressed in plain language to ensure nothing gets lost in translation.

Help and documentation.
Ideally, we want users to navigate the system without having to resort to documentation. However, depending on the type of solution, documentation may be necessary. When users require help, ensure it is easily located, specific to the task at hand and worded in a way that will guide them through the necessary steps towards a solution to the issue they are facing.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

List out the best practices of Android Security. How to prevent hacking Android phones?

A
  1. Use implicit intents and non-exported content providers:
    a. Show an app chooser
    If an implicit intent can launch at least two possible apps on a user’s device, explicitly show an app chooser. This interaction strategy allows users to transfer sensitive information to an app that they trust.

b. Apply signature-based permissions
When sharing data between two apps that you control or own, use signature-based permissions. These permissions don’t require user confirmation and instead check that the apps accessing the data are signed using the same signing key. Therefore, these permissions offer a more streamlined, secure user experience.

c. Disallow access to your app’s content providers
Unless you intend to send data from your app to a different app that you don’t own, you should explicitly disallow other developers’ apps from accessing the ContentProvider objects that your app contains. This setting is particularly important if your app can be installed on devices running Android 4.1.1 (API level 16) or lower, as the android:exported attribute of the element is true by default on those versions of Android.

d. Ask for credentials before showing sensitive information
When requesting credentials from users so that they can access sensitive information or premium content in your app, ask for either a PIN/password/pattern or a biometric credential, such as using face recognition or fingerprint recognition.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q
  1. Categorize mobile applications development tools and introduce some real products and implementations for publishing
A

We have covered best Android & iOS mobile app development tools in the following categories.

Recommended Tool
iPhone App development tools
Mobile Analytic Tools
Cross-Platform App Development Tools
App Development frameworks
AR (Augmented Reality) Tools
AI(Artificial Intelligence) Tools
Mobile Payment Tools
Push notification Tools
Game Engines

Cross-Platform App Development Tools
1) Xamarin:
Xamarin is the preferred mobile app development tool for native applications. It reuses business logic layers and data access across platforms. It is widely used to build apps for iOS, Windows, and Android app development.

  1. Appcelerator:
    Appcelerator allows developers to create apps with fewer lines of code. This app development tool supports iOS, Android, Windows, and browser-based HTML5 applications.

App Development frameworks:

  1. KendoUI:
    Kendo UI is an end-to-end mobile app development solution for modern client-side development. It follows modern web standards by providing highly modular app development solutions.
  2. Mobile Angular UI:
    Mobile Angular UI is a mobile app development framework. It relies on rich libraries like overthrow.js and fastclick.js to provide the better mobile experience.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q
  1. Demonstrate the usage of Implicit Intent with Code Snippet?
A

What is intent in Android?
Intent is an messaging object which passes between components like services, content providers, activities etc. Normally startActivity() method is used for invoking any activity.

Some of the general functions of intent are:

Start service
Launch activity
Display web page
Display contact list
Message broadcasting

Implicit Intent: Using implicit Intent, component can’t be specifying. An action to be performed is declared by implicit intent. Then android operating system will filter out component which will response to the action.

String url = editText1.getText().toString();
Intent intent=new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(intent);
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q
  1. How can we measure the UI performance of the mobile applications? Give a list of components of the UI tool kit.
A

UI response times: No app performance monitoring metrics are complete without an assessment of UI hangs. You need to constantly monitor the responsiveness of your app’s user interface for issues. Users can experience UI hangs for various reasons and if there’s a longer than usual delay (250ms on average) or a failure to respond to a user’s input, you need to be aware of it in order to fix it as soon as possible before the negative reports and comments come flooding in.

Moving forth we will see some important Android UI controls for our applications:

TextView
EditText
Button
ImageButton
ToggleButton
RadioButton
RadioGroup
CheckBox
AutoCompleteTextView
ProgressBar
Spinner
TimePicker
DatePicker
SeekBar
AlertDialog
Switch
RatingBar
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Briefly discuss about deploying APK Files.

A

Before installing an app using an APK file other than Google Play Store, we have to ensure that our Android phone settings are enabled to install third-party apps. It can be checked under the “Security” tab or the Setting menu. Generally, this option says install from unknown sources or allows third-party installations. However, the newer Android versions of phones are a little more different.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Short note on object box

A

ObjectBox is a superfast object-oriented database with strong relation support. ObjectBox is embedded into your Android, Linux, macOS, or Windows app.

ObjectBox supports multiple platforms and languages. Besides JVM based languages like Java and Kotlin, ObjectBox also offers:

ObjectBox Swift: build fast mobile apps for iOS (and macOS)
ObjectBox Dart/Flutter: cross-platform for mobile and desktop apps (beta)
ObjectBox Go: great for data-driven tools and small server applications
ObjectBox C and C++: native speed with zero copy access to FlatBuffer objects

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How MVVM architecture works

A

Developers always prefer a clean and structured code for the projects. By organizing the codes according to a design pattern helps in the maintenance of the software. By having knowledge of all crucial logic parts of the android application, it is easier to add and remove app features. Further, design patterns also assure that all the codes get covered in Unit Testing without the interference of other classes. Model — View — ViewModel (MVVM) is the industry-recognized software architecture pattern that overcomes all drawbacks of MVP and MVC design patterns. MVVM suggests separating the data presentation logic(Views or UI) from the core business logic part of the application.

The separate code layers of MVVM are:
Model: This layer is responsible for the abstraction of the data sources. Model and ViewModel work together to get and save the data.
View: The purpose of this layer is to inform the ViewModel about the user’s action. This layer observes the ViewModel and does not contain any kind of application logic.
ViewModel: It exposes those data streams which are relevant to the View. Moreover, it servers as a link between the Model and the View.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q
  1. Create a sample application to examine using the filesystem to store data, both internal to our application and external using the platform’s Secure Digital (SD) card support in Android Environment.
A

The aim of this article is to show users how to use internal storage. In this article will be creating an application that can write data to a file and store it in internal storage and read data from the file and display it on the main activity using TextView. Saving and loading data on the internal storage is private for an application that can not be accessed by other applications. When the app is uninstalled the data stored in the internal by that app is removed. To read and write in the android internal storage we have two methods

OpenFileOutput(): used for creating and saving a file. This method returns a FileOutputStream instance.
Syntax: OpenFileOutput(String filename,int mode)

Parameters:

mode:

Context.MODE_PRIVATE: If the file exists then it is overridden else a new file is created.

Context.MODE_APPEND: if the file exists then the data is appended at the end of the file.

Returns:

FileOutputStream object

OpenFileInput(): Used to read data from a file, this returns an FileInputStream instance.
Syntax: OpenFileInput( String filename)

Returns:
FileInputStream object

Step by Step Implementation
Step 1: Create a New Project

To create a new project in Android Studio please refer to How to Create/Start a New Project in Android Studio. Note that select Java as the programming language.

Step 2: Working with the activity_main.xml file

The activity_main.xml file has the following widgets

One EditText for accepting user input
Two Buttons one for reading data and the other for writing
One TextView to display the content of the file

Step 3: Working with the MainActivity.java file

Inside the MainActivity.java file we are going to do the following things:

  1. Initialize variables
  2. The file will be creating is DemoFile.txt. this can be found in Device File Explorer > data > data > application_package > files
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is android activity lifecycle. Explain briefly

A

Android Activity Lifecycle is controlled by 7 methods of android.app.Activity class. The android Activity is the subclass of ContextThemeWrapper class.

An activity is the single screen in android. It is like window or frame of Java.

By the help of activity, you can place all your UI components or widgets in a single screen.

The 7 lifecycle method of Activity describes how activity will behave at different states.

Android Activity Lifecycle methods
Let’s see the 7 lifecycle methods of android activity.

Methods:
onCreate:
called when activity is first created.
onStart:
called when activity is becoming visible to the user.
onResume:
called when activity will start interacting with the user.
onPause
called when activity is not visible to the user.
onStop
called when activity is no longer visible to the user.
onRestart
called after your activity is stopped, prior to start.
onDestroy
called before the activity is destroyed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Draw activity lifecycle diagram

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Write a program for activity lifecycle

A

It provides the details about the invocation of life cycle methods of activity. In this example, we are displaying the content on the logcat.

File: MainActivity.java
package example.javatpoint.com.activitylifecycle;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;

public class MainActivity extends Activity {

@Override  
protected void onCreate(Bundle savedInstanceState) {  
    super.onCreate(savedInstanceState);  
    setContentView(R.layout.activity_main);  
    Log.d("lifecycle","onCreate invoked");  
}  
@Override  
protected void onStart() {  
    super.onStart();  
    Log.d("lifecycle","onStart invoked");  
}  
@Override  
protected void onResume() {  
    super.onResume();  
    Log.d("lifecycle","onResume invoked");  
}  
@Override  
protected void onPause() {  
    super.onPause();  
    Log.d("lifecycle","onPause invoked");  
}  
@Override  
protected void onStop() {  
    super.onStop();  
    Log.d("lifecycle","onStop invoked");  
}  
@Override  
protected void onRestart() {  
    super.onRestart();  
    Log.d("lifecycle","onRestart invoked");  
}  
@Override  
protected void onDestroy() {  
    super.onDestroy();  
    Log.d("lifecycle","onDestroy invoked");  
}   }
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What is multimodal interface ?

A

Multimodal interfaces process two or more combined user input modes, such as speech, pen, touch, manual gestures, and gaze, in a coordinated manner with multimedia system output.

They are a new class of emerging systems that aim to recognize naturally occurring forms of human language and behavior, with the incorporation of one or more recognition-based technologies (e.g., speech, pen, vision). Multimodal interfaces represent a paradigm shift away from conventional graphical user interfaces (Fig. 1). They are being developed largely because they offer a relatively expressive, transparent, efficient, robust, and highly mobile form of human–computer interaction. They represent users’ preferred interaction style, and they support users’ ability to flexibly combine modalities or to switch from one input mode to another that may be better suited to a particular task or setting.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What are mobile agents

A

In Mobile Computing, Mobile Agents are the composition of computer software and data that can autonomously move from one computer to another computer and continue its execution on the destination computer.

In other words, you can say that An Mobile Agent is an autonomous program that is capable of moving from host to host in a network and interact with resources and other agents. In this process, the chance of data loss is scarce because the state of the running program is saved and then transported to the new host. It allows the program to continue execution from where it left off before migration. The most significant advantage of mobile agents is the possibility of moving complex processing functions to the location where you have enormous amounts of data and that have to be processed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Types of mobile agents ?

A

Mobile Agents are also called as transportable agents. They are classified into two types:

Mobile Agents with pre-defined path: They have a static migration path.
Mobile Agents with undefined path i.e., Roamer: They have dynamic migration paths. The mobile agents choose their path according to the present network condition.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

What are the four features of mobile agents ?

A

Features of Mobile Agents
The mobile agents are autonomous with intelligence, social ability, learning, and the most important feature is their mobility. They are independent in nature, self-driven and do not require a corresponding node for communication. They can work efficiently even after the user gets disconnected from the network.

Intelligence

Mobile Agents are capable of learning and searching for knowledge about their domain. That’s why they are called intelligent agents because they possess a degree of domain knowledge. They can also transport their state from one environment to another without disturbing the previous holding data and be capable of performing appropriately in the new environment.

Autonomous

The Mobile Agents are Autonomous. It means the agents are not only motivated by the outside actions initiated by the users or system but also they have internal events that decided their performance and behavior. The mobile agents can also take an autonomous decision while selecting a node.

Mobility

Mobile Agents contain some degree of mobility. The agent is not limited to its home node only. They can migrate from one node to another and can carry out tasks along with them. This feature distributes the processing and balancing of the load. Another benefit of this capability is that when the user goes offline, the agents will still keep functioning.

Communicative

Mobile Agents can communicate effectively with other agents, users and systems. The mobile agents use a communication language for inter-agent communication.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

Draw the life cycle for mobile agents

A

The life cycle of mobile agents ensures the following conditions:

They can adapt to the environment. For example, either home or foreign environment.
They are capable of switching among the positions of one node to another.
They are autonomous and focused on the final output.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

advantages and disadvantages of mobile agents ?

A

Advantages of Mobile Agents
The following are some advantages of mobile agents over conventional agents:

Mobile Agents are autonomous and self-driven in nature.
They are maintenance-friendly or easily maintainable.
They are Fault-tolerant. It means they are able to operate without an active connection between client and server.
They reduce the compilation time.
They provide less delay in the network.
They provide fewer loads on the network.
They facilitate parallel processing. It means they can be asynchronously executed on multiple heterogeneous network hosts.
They provide dynamic adaptation in which their actions are dependent on the state of the host environment.
Disadvantages of Mobile Agents
The following are some disadvantages of mobile agents:

The most significant disadvantage of mobile agents is their security. They are less secured

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

Applications of mobile agents ?

A

Mobile agents are used in the following applications:

Mobile Agents are applied in a wide range of domains such as E-commerce, traffic control, network management, robotics, data-intensive applications etc.
They are also used in grid computing, parallel computing, distributed computing and mobile computing etc.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

Advantages of gps ?

A

Advantages of Global Positioning System :

GPS is extremely easy to navigate because it tells you to direction for every turns you’re taking otherwise you need to fancy reach to your destination.
GPS works altogether weather so you would like to not worry of climate as in other navigating devices.
GPS costs you very low as compared other navigation systems.
Most attraction of this technique is its100% coverage on earth.
It also helps you to look nearby restaurants, hotels and gas stations and is extremely useful for a replacement place.
Due to its low cost, it’s very easy to integrate into other technologies like telephone.
System is updated regularly by United States government and hence is extremely advance.
This is the simplest navigating system in water as in larger water bodies we are often misled thanks to lack of proper directions.
GPS signal is out there worldwide. Therefore, users won’t be bereft of it anywhere.
GPS are often used anywhere within world, it’s powered by world satellites, so it are often accessed anywhere, a solid tracking system and a GPS receiver are all you would like.

26
Q

Disadvantages of GPS ?

A

Disadvantages of worldwide Positioning System :

Sometimes GPS may fail thanks to certain reasons and therein case you would like to hold a backup map and directions.
If you’re using GPS on A battery operated device, there could also be A battery failure and you’ll need a external power supply which isn’t always possible.
Sometimes GPS signals aren’t accurate thanks to some obstacles to signals like buildings, trees and sometimes by extreme atmospheric conditions like geomagnetic storms.
GPS chip is hungry for power which drains battery in 8 to 12 hours. this needs replacement or recharge of battery quite frequently.
GPS doesn’t penetrate solid walls or structures. it’s also suffering from large constructions or structures.

27
Q

How data persistency is achieved in android ?

A

Android allows to persists application data via the file system. For each application the Android system creates a data/data/[application package] directory.

Android supports the following ways of storing data in the local file system:

Files - You can create and update files

Preferences - Android allows you to save and retrieve persistent key-value pairs of primitive data type.

SQLite database - instances of SQLite databases are also stored on the local file system.

Files are saved in the files folder and application settings are saved as XML files in the shared_prefs folder.

If your application creates an SQLite database this database is saved in the main application directory under the databases folder.

28
Q

Simple definition of implicit and explicit intents ?

A

Explicit: when we want to communicate between two activities in the same application.
Implicit: when we want to communicate between two different applications .

29
Q
  1. Explain the security issues in mobile application development.
A

There are mainly five fundamental goals of security used in the information system to deal with security issues. They are:

Confidentiality

This is used to prevent unauthorized users from gaining access to any particular user’s critical and confidential information.

Integrity

This is used to ensure that any type of unauthorized modification, destruction or creation of information cannot be done.

Availability

The availability is used to ensure that authorized users get the required access whenever they need it.

Legitimate

This is used to ensure that only authorized, and legitimate users have access to the services.

Accountability

Accountability is used to ensure that the users will be responsible for their security-related activities by arranging the users and their activities in a linked form.

We have to achieve these goals according to the security policy used by the service providers.

30
Q

What are wireless security issues ?

A

Wireless Security Issues
Wireless security issues are considered as the primary security issues of mobile computing. These are related to wireless networks. These issues occur when the hackers intercept the radio signals. Most wireless networks are dependent on other private networks, which are managed by others, so after these issues, the users have less control of security procedures. These security issues are:

Denial of Service (DOS) attacks

The denial of services or DOS attacks is one of the most common attacks of all kinds of networks and especially in a wireless network. It prevents users from using network services because the attacker sends a large amount of unnecessary data or connection requests to the communication server. It causes a slow network, and therefore the users cannot get benefitted from using its service.

Traffic Analysis

Traffic analysis is used to identify and monitor communication between users. In this process, the service provider listens the traffic flowing in the wireless channel to access the private information of users affected by the attacker.

Eavesdropping

It specifies that the attacker can log on to the wireless network and access sensitive data if the wireless network was not secure enough. This can also be done if the information is not encrypted.

Session Interception and Messages Modification

It specifies that the attacker can intercept the session and modify the transmitted data in this session. This scenario is called “man in the middle.” It inserts the attacker’s host between the sender and receiver host.

Spoofing

In this security issue, the attacker impersonates him as an authorized account of another user and tries to access the sensitive data and unauthorized services.

Captured and Retransmitted Messages

In this security issue, the attacker can get some of the network services by getting unauthorized access. After capturing the message, he/she can reply to it with some modifications to the same destination or another.

31
Q

How to handle security issues ?

A

The biggest issue in mobile computing is the credential verification of users. Because the users share the username and passwords, it may become a significant threat to security. Due to this sensitive issue, most companies are very reluctant to implement mobile computing. Some recommendations can be followed by companies or mobile users to keep their mobile devices and the data stored in the devices secure.

The company should hire qualified personnel.
You should install security hardware and software.
You should ensure that the data stored in the mobile devices are encrypted and audited.
Educate the users on proper mobile computing ethics and security issues.
You must ensure that the mobile devices are configured with a power-on authentication to prevent unauthorized access if lost or stolen.
You must ensure that anti-virus software is installed on mobile devices.
Make sure that the firewall client is installed on mobile devices.
Make your mobile devices encrypted with a strong password.
Encrypt your data stored in the secondary storage devices such as Memory Sticks, Data card, removable USB etc.
Ensure that the Bluetooth, Wi-Fi, etc. enabled mobile devices are turned off when you are not using them.
Make periodic backups of your mobile devices on a data server.

32
Q
  1. Discuss in detail about storing and retrieving data. How to store data locally in an Android app? Explain.
A

There are many ways to store and retrieve data in android:

1.Storing and retrieving data with SharedPreferences
2.Using the filesystem
3 Working with a SQLite database
4 Accessing and building a ContentProvider

33
Q

How data storage with sharedPreference works ?

A

5.1. Using preferences
If you want to share simple application data from one Activity to another, use a SharedPreferences object. You can save and retrieve data, and also choose whether to make preferences private to your application or accessible to other applications on the same device.

5.1.1. Working with SharedPreferences
You access a SharedPreferences object through your current Context, such as the Activity or Service. Context defines the method getSharedPreferences(String name, int accessMode) that allows you to get a preferences handle. The name you specify will be the name for the file that backs these preferences. If no such file exists when you try to get preferences, one is automatically created. The access mode refers to what permissions you want to allow.

34
Q

How data storage with filesystem works ?

A

Android’s filesystem is based on Linux and supports mode-based permissions. You can access this filesystem in several ways. You can create and read files from within applications, you can access raw resource files, and you can work with specially compiled custom XML files. In this section, we’ll explore each approach.

35
Q

Write a Program to Demonstrate the use of Scroll View on android platform.

A

The android.widget.ScrollView class provides the functionality of scroll view. ScrollView is used to scroll the child elements of palette inside ScrollView. Android supports vertical scroll view as default scroll view. Vertical ScrollView scrolls elements vertically.

Android uses HorizontalScrollView for horizontal ScrollView.

Let’s implement simple example of vertical ScrollView.

package com.example.test.scrollviews;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class MainActivity extends AppCompatActivity {

@Override  
protected void onCreate(Bundle savedInstanceState) {  
    super.onCreate(savedInstanceState);  
    setContentView(R.layout.activity_main);  
}   }  

File: MainActivity.java

package com.example.test.scrollviews;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class MainActivity extends AppCompatActivity {

@Override  
protected void onCreate(Bundle savedInstanceState) {  
    super.onCreate(savedInstanceState);  
    setContentView(R.layout.activity_main);  
}   }
36
Q

What is multi threading in android ?

A

Working on multiple tasks at the same time is Multitasking. In the same way, multiple threads running at the same time in a machine is called Multi-Threading. Technically, a thread is a unit of a process. Multiple such threads combine to form a process. This means when a process is broken, the equivalent number of threads are available.
For example, Autocorrect is the process where the software looks for the mistakes in the current word being typed. Endlessly checking for the mistake and providing suggestions at the same time is an example of a Multi-Threaded process.

37
Q

What is concurrency ?

A

Concurrency is the concept of executing two or more tasks at the same time (in parallel). Tasks may include methods (functions), parts of a program, or even other programs. With current computer architectures, support for multiple cores and multiple processors in a single CPU is very common.

38
Q
  1. Draw the service life cycle of started service and Bound service of Android
A

A service is a component that runs in the background to perform long-running operations without needing to interact with the user and it works even if application is destroyed. A service can essentially take two states −

Started

A service is started when an application component, such as an activity, starts it by calling startService(). Once started, a service can run in the background indefinitely, even if the component that started it is destroyed.

Bound

A service is bound when an application component binds to it by calling bindService(). A bound service offers a client-server interface that allows components to interact with the service, send requests, get results, and even do so across processes with interprocess communication (IPC).

39
Q
  1. Design a program that demonstrate Activity Life cycle of any android application.
A

File: activity_main.xml

Android Activity Lifecycle Example
It provides the details about the invocation of life cycle methods of activity. In this example, we are displaying the content on the logcat.

File: MainActivity.java
package example.javatpoint.com.activitylifecycle;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;

public class MainActivity extends Activity {

@Override  
protected void onCreate(Bundle savedInstanceState) {  
    super.onCreate(savedInstanceState);  
    setContentView(R.layout.activity_main);  
    Log.d("lifecycle","onCreate invoked");  
}  
@Override  
protected void onStart() {  
    super.onStart();  
    Log.d("lifecycle","onStart invoked");  
}  
@Override  
protected void onResume() {  
    super.onResume();  
    Log.d("lifecycle","onResume invoked");  
}  
@Override  
protected void onPause() {  
    super.onPause();  
    Log.d("lifecycle","onPause invoked");  
}  
@Override  
protected void onStop() {  
    super.onStop();  
    Log.d("lifecycle","onStop invoked");  
}  
@Override  
protected void onRestart() {  
    super.onRestart();  
    Log.d("lifecycle","onRestart invoked");  
}  
@Override  
protected void onDestroy() {  
    super.onDestroy();  
    Log.d("lifecycle","onDestroy invoked");  
}   }
40
Q
  1. Write an Android program that demonstrate Toast in an application
A

Andorid Toast can be used to display information for the short period of time. A toast contains message to be displayed quickly and disappears after sometime.

The android.widget.Toast class is the subclass of java.lang.Object class.

You can also create custom toast as well for example toast displaying image. You can visit next page to see the code for custom toast.

File: MainActivity.java
package example.javatpoint.com.toast;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

@Override  
protected void onCreate(Bundle savedInstanceState) {  
    super.onCreate(savedInstanceState);  
    setContentView(R.layout.activity_main);  
        //Displaying Toast with Hello Javatpoint message  
        Toast.makeText(getApplicationContext(),"Hello Javatpoint",Toast.LENGTH_SHORT).show();  
    }  
}
41
Q
  1. Discuss the process of database connectivity using SQLite
A

SQLite is a opensource SQL database that stores data to a text file on a device. Android comes in with built in SQLite database implementation.

SQLite supports all the relational database features. In order to access this database, you don’t need to establish any kind of connections for it like JDBC,ODBC e.t.c

Database - Package
The main package is android.database.sqlite that contains the classes to manage your own databases

Database - Creation
In order to create a database you just need to call this method openOrCreateDatabase with your database name and mode as a parameter. It returns an instance of SQLite database which you have to receive in your own object.Its syntax is given below

SQLiteDatabase mydatabase = openOrCreateDatabase(“your database name”,MODE_PRIVATE,null);

openDatabase(String path, SQLiteDatabase.CursorFactory factory, int flags, DatabaseErrorHandler errorHandler)

This method only opens the existing database with the appropriate flag mode. The common flags mode could be OPEN_READWRITE OPEN_READONLY

42
Q
  1. Explain the content provider architecture diagram with suitable diagram.
A

In Android, Content Providers are a very important component that serves the purpose of a relational database to store the data of applications. The role of the content provider in the android system is like a central repository in which data of the applications are stored, and it facilitates other applications to securely access and modifies that data based on the user requirements. Android system allows the content provider to store the application data in several ways. Users can manage to store the application data like images, audio, videos, and personal contact information by storing them in SQLite Database, in files, or even on a network. In order to share the data, content providers have certain permissions that are used to grant or restrict the rights to other applications to interfere with the data.

43
Q

What are android web services ?

A

A web service is basically required to provide interoperability, i.e. connecting various applications. It allows different apps to communicate with each other and share the data and services among themselves. Web services provide a standard for all the types of client applications to invoke functions on every type of app server.

For example, you can consider an android application interacting with a .NET app using a web service.

Characteristics of Web Services in Android
Before knowing more about web-services, we’ll understand some of the behavioral characteristics.

  1. Web services are XML – based. They use it at its data representational layer and its transportational layer as it removes networking, operating system or even the platform binding. These services are highly interoperable at their core level.
  2. Web services are loosely coupled. That means the consumer web services and providers of web service are not tied together directly.
  3. Web services have the ability to be either Synchronous or Asynchronous. Here Synchronous can be understood as binding the client to the execution of the service. On the other hand, Asynchronous refers to allowing the client to invoke a service first and later executing the other functions.
  4. Web Services supports Remote Procedure Calls. Remote Procedure calls can often be referred to as RPCs. These RPCs let the clients invoke various functions, methods, and services on remote objects using XML.
  5. There is support to Document exchange in Web Services. In fact, XML has a very generic way to represent data as well as complex documents. Along with that, it has got various ways to represent these documents.
44
Q

How to establish android development environment ?

A

You will be glad to know that you can start your Android application development on either of the following operating systems −

Microsoft Windows XP or later version.

Mac OS X 10.5.8 or later version with Intel chip.

Linux including GNU C Library 2.7 or later.

Second point is that all the required tools to develop Android applications are freely available and can be downloaded from the Web. Following is the list of software’s you will need before you start your Android application programming.

Java JDK5 or later version

Android Studio

45
Q

Explain data persistence using core data ?

A

CoreData (data layer management framework) saves data into something called a persistent store. The store is where the data lives. There are 3 different types of stores CoreData supports on iOS;
SQLite Store (default)
Binary Store
In-memory Store
SQLite is almost always the right choice of your persistent store in a SQL relational database.
Binary store can be appropriate when you always need the database to be read and written in its entirety.
In-memory store can be appropriate when you have a small data model can fit in memory all at once and that does not need to be saved to disk. (like cache)

45
Q

Explain data persistence using core data ?

A

CoreData (data layer management framework) saves data into something called a persistent store. The store is where the data lives. There are 3 different types of stores CoreData supports on iOS;
SQLite Store (default)
Binary Store
In-memory Store
SQLite is almost always the right choice of your persistent store in a SQL relational database.
Binary store can be appropriate when you always need the database to be read and written in its entirety.
In-memory store can be appropriate when you have a small data model can fit in memory all at once and that does not need to be saved to disk. (like cache)

46
Q

how user preferences are stored in android environment ?

A

One of the most Interesting Data Storage options Android provides its users is Shared Preferences. 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. Shared Preferences can be thought of as a dictionary or a key/value pair. For example, you might have a key being “username” and for the value, you might store the user’s username. And then you could retrieve that by its key (here username). You can have a simple shared preference API that you can use to store preferences and pull them back as and when needed. Shared Preferences class provides APIs for reading, writing, and managing this data.

47
Q

How to use core location ?

A

Core Location provides services that determine a device’s geographic location, altitude, and orientation, or its position relative to a nearby iBeacon device. The framework gathers data using all available components on the device, including the Wi-Fi, GPS, Bluetooth, magnetometer, barometer, and cellular hardware.

You use instances of the CLLocationManager class to configure, start, and stop the Core Location services

A location manager object supports the following location-related activities:

Standard and significant location updates. Track large or small changes in the user’s current location with a configurable degree of accuracy.

Region monitoring. Monitor distinct regions of interest and generate location events when the user enters or leaves those regions.

Beacon ranging. Detect and locate nearby beacons.

Compass headings. Report heading changes from the onboard compass.

48
Q

different ways Activities could use to communicate with Services on Android.

A

different ways Activities could use to communicate with Services on Android.
1. Using Intent
1.1. Context.startService()
The simplest way to communicate with a Service is to send an Intent through Context.startService(),
1.2. Context.sendBroadcast()
A similar way is to use Context.sendBroadcast() to send an intent

  1. Bound Service
    2.1. Extending Binder
    We can implement own Binder class to provide direct access to the service instance:
    2.2. Using Messenger
    We talked about this approach in a previous article, Loopers and Handlers in Android.
49
Q

Short note on android fragments

A

Android Fragments
Android Fragment is the part of activity, it is also known as sub-activity. There can be more than one fragment in an activity. Fragments represent multiple screen inside one activity.

Android fragment lifecycle is affected by activity lifecycle because fragments are included in activity.

Each fragment has its own life cycle methods that is affected by activity life cycle because fragments are embedded in activity.

The FragmentManager class is responsible to make interaction between fragment objects.

50
Q

Storage options in sqlite

A

Each value stored in an SQLite database (or manipulated by the database engine) has one of the following storage classes:

NULL. The value is a NULL value.

INTEGER. The value is a signed integer, stored in 0, 1, 2, 3, 4, 6, or 8 bytes depending on the magnitude of the value.

REAL. The value is a floating point value, stored as an 8-byte IEEE floating point number.

TEXT. The value is a text string, stored using the database encoding (UTF-8, UTF-16BE or UTF-16LE).

BLOB. The value is a blob of data, stored exactly as it was input.

51
Q

How to store data in external storage and what permissions are required ?

A

External Storage Availability
In order to avoid crashing the app first, we need to check storage SD Card is available for reading and write operations. The method getExternalStorageState() is used to determine the state of mounted storage media such as SD Card is missing, read-only or readable, and writable. Below is the code snippet which we will use to check the availability of external storage.

Methods to Store data in External Storage
getExternalStoragePublicDirectory(): This is the present recommended method to keep files public and these files are not deleted even when the app is uninstalled from the system. For eg: Images clicked by the camera are still available even after we uninstall the camera.
getExternalFilesDir(String type): This method is used to store private data that are specific to the app only. And data are removed as we uninstall the app.
getExternalStorageDirectory(): This method is not recommended. It is now absolute and it is used to access external storage in older versions, API Level less than 7.

Step 2: Access Permission to External Storage

To read and write data to external storage, the app required WRITE_EXTERNAL_STORAGE and READ_EXTERNAL_STORAGE system permission. These permissions are added to the AndroidManifest.xml file. Add these permissions just after the package name.

52
Q

How to create a content provider ?

A

Creating a Content Provider
Following are the steps which are essential to follow in order to create a Content Provider:

Create a class in the same directory where the that MainActivity file resides and this class must extend the ContentProvider base class.
To access the content, define a content provider URI address.
Create a database to store the application data.
Implement the six abstract methods of ContentProvider class.
Register the content provider in AndroidManifest.xml file using tag.
Following are the six abstract methods and their description which are essential to override as the part of ContenProvider class:

53
Q

Normally, in the process of carrying out a screen reorientation, the Android platform tears down the foreground activity and recreates it, restoring each of the view values in the activity’s layout. In an app you’re working on, you notice that a view’s value is not being restored after screen reorientation. What could be a likely cause of the problem that you should verify, at a minimum, about that particular view? Discuss with suitable example.

A

You should verify that it has a valid id. In order for the Android system to restore the state of the views in your activity, each view must have a unique ID, supplied by the android:id attribute.

54
Q

Suppose that you are starling a service in an Activity as follows: Intent service = new Intent (context, MyService.class); startService(service); where Myservice accesses a remote server via an Internet connection. If the Activity is showing an animation that indicates some kind of progress. Discuss the issues might you encounter and how could you address it?

A

Responses from a remote service via the Internet can often take some time, either due to networking latencies, or load on the remote server, or the amount of time it takes for the remote service to process and respond to the request.

As a result, if such a delay occurs, the animation in the activity (and even worse, the entire UI thread) could be blocked and could appear to the user to be “frozen” while the client waits for a response from the service. This is because the service is started on the main application thread (or UI thread) in the Activity.

The problem can (and should) be avoided by relegating any such remote requests to a background thread or, when feasible, using an an asynchronous response mechanism.

Note well: Accessing the network from the UI thread throws a runtime exception in newer Android versions which causes the app to crash.

55
Q

draw the android architecture

A

Android architecture contains different number of components to support any android device needs. Android software contains an open-source Linux Kernel having collection of number of C/C++ libraries which are exposed through an application framework services.

Among all the components Linux Kernel provides main functionality of operating system functions to smartphones and Dalvik Virtual Machine (DVM) provide platform for running an android application.

The main components of android architecture are following:-

Applications
Application Framework
Android Runtime
Platform Libraries
Linux Kernel
Pictorial representation of android architecture with several main components and their sub components –

Applications –
Applications is the top layer of android architecture. The pre-installed applications like home, contacts, camera, gallery etc and third party applications downloaded from the play store like chat applications, games etc. will be installed on this layer only.
It runs within the Android run time with the help of the classes and services provided by the application framework.

Application framework –
Application Framework provides several important classes which are used to create an Android application. It provides a generic abstraction for hardware access and also helps in managing the user interface with application resources. Generally, it provides the services with the help of which we can create a particular class and make that class helpful for the Applications creation.

It includes different types of services activity manager, notification manager, view system, package manager etc. which are helpful for the development of our application according to the prerequisite.

Application runtime –
Android Runtime environment is one of the most important part of Android. It contains components like core libraries and the Dalvik virtual machine(DVM). Mainly, it provides the base for the application framework and powers our application with the help of the core libraries.

Like Java Virtual Machine (JVM), Dalvik Virtual Machine (DVM) is a register-based virtual machine and specially designed and optimized for android to ensure that a device can run multiple instances efficiently. It depends on the layer Linux kernel for threading and low-level memory management. The core libraries enable us to implement android applications using the standard JAVA or Kotlin programming languages.

Platform libraries –
The Platform Libraries includes various C/C++ core libraries and Java based libraries such as Media, Graphics, Surface Manager, OpenGL etc. to provide a support for android development.

Media library provides support to play and record an audio and video formats.
Surface manager responsible for managing access to the display subsystem.
SGL and OpenGL both cross-language, cross-platform application program interface (API) are used for 2D and 3D computer graphics.
SQLite provides database support and FreeType provides font support.
Web-Kit This open source web browser engine provides all the functionality to display web content and to simplify page loading.
SSL (Secure Sockets Layer) is security technology to establish an encrypted link between a web server and a web browser.
Linux Kernel –
Linux Kernel is heart of the android architecture. It manages all the available drivers such as display drivers, camera drivers, Bluetooth drivers, audio drivers, memory drivers, etc. which are required during the runtime.

The Linux Kernel will provide an abstraction layer between the device hardware and the other components of android architecture. It is responsible for management of memory, power, devices etc.

The features of Linux kernel are:

Security: The Linux kernel handles the security between the application and the system.
Memory Management: It efficiently handles the memory management thereby providing the freedom to develop our apps.
Process Management: It manages the process well, allocates resources to processes whenever they need them.
Network Stack: It effectively handles the network communication.
Driver Model: It ensures that the application works properly on the device and hardware manufacturers responsible for building their drivers into the Linux build.

56
Q

Write down query string to return a list of all internal images and list of all calls registered in the Call Log?

A
public static class CallLog.Calls
extends Object implements BaseColumns

java.lang.Object
↳ android.provider.CallLog.Calls

Contains the recent calls.

Note: If you want to query the call log and limit the results to a single value, you should append the LIMIT_PARAM_KEY parameter to the content URI. For example:

getContentResolver().query(
Calls.CONTENT_URI.buildUpon().appendQueryParameter(LIMIT_PARAM_KEY, “1”)
.build(),
null, null, null, null);

57
Q

What is the role of query string in content providers ?

A

Content URI(Uniform Resource Identifier) is the key concept of Content providers. To access the data from a content provider, URI is used as a query string.

Structure of a Content URI: content://authority/optionalPath/optionalID

Details of different parts of Content URI:

content:// – Mandatory part of the URI as it represents that the given URI is a Content URI.
authority – Signifies the name of the content provider like contacts, browser, etc. This part must be unique for every content provider.
optionalPath – Specifies the type of data provided by the content provider. It is essential as this part helps content providers to support different types of data that are not related to each other like audio and video files.
optionalID – It is a numeric value that is used when there is a need to access a particular record.

58
Q

Three ways for data persistence

A

For Android, there are primarily three basic ways of persisting data:

A lightweight mechanism known as shared preferences to save small chunks of data
Traditional file systems
A relational database management system through the support of SQLite databases

59
Q

A standard Android device has multiple physical keys that can trigger events. List down the possible physical keys along with their Key Event name and description.

A

Broadcast in android is the system-wide events that can occur when the device starts, when a message is received on the device or when incoming calls are received, or when a device goes to airplane mode, etc. Broadcast Receivers are used to respond to these system-wide events. Broadcast Receivers allow us to register for the system and application events, and when that event happens, then the register receivers get notified. There are mainly two types of Broadcast Receivers:

Static Broadcast Receivers: These types of Receivers are declared in the manifest file and works even if the app is closed.
Dynamic Broadcast Receivers: These types of receivers work only if the app is active or minimized.

The two main things that we have to do in order to use the broadcast receiver in our application are:

Creating the Broadcast Receiver:

class AirplaneModeChangeReceiver:BroadcastReceiver() {

   override fun onReceive(context: Context?, intent: Intent?) {

        // logic of the code needs to be written here

  }

}

Registering a BroadcastReceiver:

IntentFilter(Intent.ACTION_AIRPLANE_MODE_CHANGED).also {

                 // receiver is the broadcast receiver that we have registered

                // and it is the intent filter that we have created

                registerReceiver(receiver,it)

  }
60
Q

program a calculator

A

import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

EditText e1, e2;
TextView t1;
int num1, num2;

@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_main);
}
	// a public method to get the input numbers
	public boolean getNumbers() {
		// defining the edit text 1 to e1
		e1 = (EditText) findViewById(R.id.num1);
		// defining the edit text 2 to e2
		e2 = (EditText) findViewById(R.id.num2);
		// defining the text view to t1
		t1 = (TextView) findViewById(R.id.result);
		// taking input from text box 1
		String s1 = e1.getText().toString();
		// taking input from text box 2
		String s2 = e2.getText().toString();
		// condition to check if box is not empty
		if ((s1.equals(null) && s2.equals(null))
				|| (s1.equals("") && s2.equals(""))) {
		String result = "Please enter a value";
		t1.setText(result);
			return false;
		} else {
			// converting string to int.
			num1 = Integer.parseInt(s1);
			// converting string to int.
			num2 = Integer.parseInt(s2);
		}
	return true;
}
	// a public method to perform addition
	public void doSum(View v) {
		// get the input numbers
		if (getNumbers()) {
			int sum = num1 + num2;
			t1.setText(Integer.toString(sum));
		}
	}
	// a public method to perform power function
	public void doPow(View v) {
		// get the input numbers
		if (getNumbers()) {
			double sum = Math.pow(num1, num2);
			t1.setText(Double.toString(sum));
		}
	}
	// a public method to perform subtraction
	public void doSub(View v) {
		// get the input numbers
		if (getNumbers()) {
			int sum = num1 - num2;
			t1.setText(Integer.toString(sum));
		}
	}
	// a public method to perform multiplication
	public void doMul(View v) {
		// get the input numbers
		if (getNumbers()) {
			int sum = num1 * num2;
			t1.setText(Integer.toString(sum));
		}
	}
	// a public method to perform Division
	public void doDiv(View v) {
		// get the input numbers
		if (getNumbers()) {
			// displaying the text in text view assigned as t1
			double sum = num1 / (num2 * 1.0);
			t1.setText(Double.toString(sum));
		}
	}
	// a public method to perform modulus function
	public void doMod(View v) {
		// get the input numbers
		if (getNumbers()) {
			double sum = num1 % num2;
			t1.setText(Double.toString(sum));
		}
	}
}
61
Q

How to prevent android hacking ?

A
  1. Prevent decompilation
    Obtaining the source code of an unprotected application is not a problem for an experienced developer. To do this, simply convert to jar dex files, and then extract the source-code which is easy to read. This can be prevented with the help of special tools: JAD, JD-GUI, and dex2jar.
  2. Transfer part of the application to the server
    One of the most effective ways to protect an application is to transfer a critical part of a program to a server — for example, unique algorithms. In this case, important data will be saved from hacking due to the fact that penetrating a properly configured server is an extremely difficult task.
  3. Encryption
    If the application transmits data to the server, then SSL should be used. However, its use must be approached responsibly. About 40% of all applications using SSL are vulnerable to a man-in-the-middle attack.
  4. Storage of important user data in processed form
    It is not a good idea to store important user information plainly. It is better to process it using a special algorithm.
  5. Work with credentials
    In order for the application to be protected, you need to refuse to store the password on the user’s device (for a permanent login, it is better to use the Credential object). It is also important in the application to minimize the number of credential requests. You should contact top mobile app development companies to hire App developers for the development of your mobile app.