7 minutes

Android Interview Questions And Answers

By Nilanchala @nilan, On Sep 17, 2023 Android 2.24K Views

This post answers some of the common android interview questions and answers.

How to send SMS in Android?

You may send sms either using SmsManager or by invoking Built-in SMS application

Sending SMS using SmsManager API

SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage("", null, "< message body>", null, null);

SmsManager require, SMS_SEND permission in your android mainfeast.

Sending SMS by invoking Built-in SMS application

Intent sendIntent = new Intent(Intent.ACTION_VIEW);
sendIntent.putExtra("sms_body", “"); 

How to Make a call in Android?

Intent callIntent = new Intent(Intent.ACTION_CALL);

How to send Email in Android?

Android Intent is the handy way to send Email using your app.

String to = toEmail.getText().toString(); 
String subject = emailSubject.getText().toString();
String message = emailBody.getText().toString(); 
Intent email = new Intent(Intent.ACTION_SEND); 
email.putExtra(Intent.EXTRA_EMAIL, new String[] { to }); 
email.putExtra(Intent.EXTRA_SUBJECT, subject); 
email.putExtra(Intent.EXTRA_TEXT, message);  

// need this to prompts email client only 
startActivity(Intent.createChooser(email, "Choose an Email client"));

How to integrating sharing in Android?

Android API made sharing feature handy. You don’t need to integrate the third party applications SDK’s like Facebook, twitter. Just a step to use share intent and it makes your application ready to share data to your social networks.

Intent sendIntent = new Intent();
sendIntent.putExtra(Intent.EXTRA_TEXT, "This is my text to send.");
startActivity(Intent.createChooser(sendIntent, getResources().getText(R.string.send_to)));

How to open link in Android Browser?

Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(""));

How to Display HTML in Android TextView?

In android there is a lovely class android.text.HTML that processes HTML strings into displayable styled text. Currently android doesn’t support all HTML tags.

Html.formHtml() method takes an Html.TagHandler and an Html.ImageGetter as arguments as well as the text to parse. We can parse null as for the Html.TagHandler but you’d need to implement your own Html.ImageGetter as there isn’t a default implementation. The Html.ImageGetter needs to run synchronously and if you’re downloading images from the web you’ll probably want to do that asynchronously. But in my example I am using the images from resources to make my ImageGetter implementation simpler.

String htmlText = "<html><body>....</body></html>";
TextView htmlTextView = (TextView)findViewById(;
htmlTextView.setText(Html.fromHtml(htmlText, new ImageGetter(), null));

How to display Android Toast?

Toast is a notification message that pop up, display a certain amount of time, and automatically fades in and out, most people just use it for debugging purpose. Below is the code snippets to create a Toast message

//display in short period of time
Toast.makeText(getApplicationContext(), "msg msg", Toast.LENGTH_SHORT).show();

//display in long period of time
Toast.makeText(getApplicationContext(), "msg msg", Toast.LENGTH_LONG).show();

Android custom toast example

How to Pass data between Activities in android

We an pass values between the activities, by using Bundles. Use below code to send data from ActivityA

String name="StackTips";
String url="";
Intent intent=new Intent(ActivityA.this, ActivityB.class);
intent.putExtra("name", name);
intent.putExtra("url", url);

Now, you can retrieve the data in ActivityB using below code

Bundle bundle = new Bundle();
bundle = getIntent().getExtras();
String name = bundle.getString("name");
String url = bundle.getString("url");
nilan avtar


I'm a blogger, educator and a full stack developer. Mainly focused on Java, Spring and Micro-service architecture. I love to learn, code, make and break things.