Generally while we making an android application then sometimes we need small piece of code like how to call a number on button click, how to send an email, how to send a sms. But problem is that it does not available at one place. So i am giving all possible Utility code here
2) How to send an email in android application
Note : Never forget to mention for sending SMS <uses-permission android:name="android.permission.SEND_SMS"></uses-permission>
1) How to call a number in android application
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:123456789"));
startActivity(callIntent);
2) How to send an email in android application
Intent(android.content.Intent.ACTION_SENDTO);
emailIntent.setType("text/html");
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "testing email send.");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml("<b>this is html text in email body.</b>"));
startActivity(Intent.createChooser(emailIntent, "Email to Friend"));
SmsManager sm = SmsManager.getDefault();
String number = "6508570720";
sm.sendTextMessage(number, null, "Test SMS Message", null, null);
Note : Never forget to mention for sending SMS <uses-permission android:name="android.permission.SEND_SMS"></uses-permission>
Now enjoy these Utility in your application and feel free to support me by commenting and giving feedback
No comments:
Post a Comment