Overview
This page documents commonly asked Android interview questions with practical code examples. The answers focus on core Android concepts frequently tested in technical interviews, including messaging, calling, intents, data sharing, and UI handling.
How to Send SMS in Android
SMS can be sent in Android using either the SmsManager API or by invoking the default SMS application.
Sending SMS Using SmsManager API
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(
null,
null,
"Message body",
null,
null
);
This approach requires the SEND_SMS permission to be declared in the Android manifest file.
<uses-permission android:name="android.permission.SEND_SMS"/>
Sending SMS Using Built-in SMS Application
Intent sendIntent = new Intent(Intent.ACTION_VIEW);
sendIntent.putExtra("sms_body", "Message body");
sendIntent.setType("vnd.android-dir/mms-sms");
startActivity(sendIntent);
This method launches the default messaging application with prefilled content.
How to Make a Call in Android
To initiate a phone call programmatically, use the ACTION_CALL intent.
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:03777788"));
startActivity(callIntent);
This requires the CALL_PHONE permission.
<uses-permission android:name="android.permission.CALL_PHONE"/>
How to Send Email in Android
Email can be sent using Android intents without integrating any third-party SDK.
String to = toEmail.getText().toString();
String subject = emailSubject.getText().toString();
String message = emailBody.getText().toString();
Intent emailIntent = new Intent(Intent.ACTION_SEND);
emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[]{to});
emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
emailIntent.putExtra(Intent.EXTRA_TEXT, message);
emailIntent.setType("message/rfc822");
startActivity(Intent.createChooser(emailIntent, "Choose Email Client"));
This ensures that only email applications are shown in the chooser dialog.
How to Integrate Sharing in Android
Android provides built-in sharing support using intents, eliminating the need for third-party SDKs.
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_TEXT, "This is my text to send");
shareIntent.setType("text/plain");
startActivity(Intent.createChooser(
shareIntent,
getResources().getText(R.string.send_to)
));
This allows content to be shared across supported applications such as messaging and social platforms.
How to Open a Link in Android Browser
To open a web URL in the default browser, use the ACTION_VIEW intent.
Intent browserIntent = new Intent(
Intent.ACTION_VIEW,
Uri.parse("https://javatechig.com")
);
startActivity(browserIntent);
How to Display HTML in Android TextView
Android provides the Html utility class to render HTML content inside a TextView.
String htmlText = "<html><body>HTML content</body></html>";
TextView htmlTextView = findViewById(R.id.html_text);
htmlTextView.setText(
Html.fromHtml(htmlText, Html.FROM_HTML_MODE_LEGACY)
);
Not all HTML tags are supported. Images require a custom Html.ImageGetter implementation.
How to Display Android Toast Messages
Toast messages are short-lived notifications used for brief feedback.
Toast.makeText(
getApplicationContext(),
"Message",
Toast.LENGTH_SHORT
).show();
For longer duration:
Toast.makeText(
getApplicationContext(),
"Message",
Toast.LENGTH_LONG
).show();
How to Pass Data Between Activities in Android
Data can be passed between activities using intent extras.
Sending Data from Activity A
Intent intent = new Intent(ActivityA.this, ActivityB.class);
intent.putExtra("name", "Javatechig");
intent.putExtra("url", "https://javatechig.com");
startActivity(intent);
Receiving Data in Activity B
Bundle bundle = getIntent().getExtras();
if (bundle != null) {
String name = bundle.getString("name");
String url = bundle.getString("url");
}


