From 4ba38c25fc30a029d669aece2fffa20817e75547 Mon Sep 17 00:00:00 2001 From: Asad Date: Sun, 12 Aug 2018 22:20:51 +0500 Subject: [PATCH] Add function SendSMS --- .idea/codeStyles/Project.xml | 29 +++++++++++++++++ .idea/modules.xml | 3 ++ .../com/androidsocialutils/SocialUtils.java | 32 +++++++++++++++++++ .../com/socialutilshelper/MainActivity.java | 2 ++ app/src/main/res/drawable/ic_menu_sms.xml | 9 ++++++ .../main/res/menu/activity_main_drawer.xml | 4 +++ 6 files changed, 79 insertions(+) create mode 100644 .idea/codeStyles/Project.xml create mode 100644 app/src/main/res/drawable/ic_menu_sms.xml diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..30aa626 --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml index 6420e94..1ec7ea4 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -2,8 +2,11 @@ + + + diff --git a/androidsocialutils/src/main/java/pavelpoley/com/androidsocialutils/SocialUtils.java b/androidsocialutils/src/main/java/pavelpoley/com/androidsocialutils/SocialUtils.java index 0d06227..7579475 100644 --- a/androidsocialutils/src/main/java/pavelpoley/com/androidsocialutils/SocialUtils.java +++ b/androidsocialutils/src/main/java/pavelpoley/com/androidsocialutils/SocialUtils.java @@ -102,4 +102,36 @@ public static void sendEmail(@NonNull Context context,@NonNull String mailTo,@No context.startActivity(Intent.createChooser(intent, "Send email...")); } + + + /** + * Send SMS + * @param context the context + * @param message message that will intend to be sent as sms body + * */ + + public static void sendSMS(@NonNull Context context,@NonNull String message) + { + Intent smsIntent = new Intent(android.content.Intent.ACTION_VIEW); + smsIntent.setType("vnd.android-dir/mms-sms"); + smsIntent.putExtra("address",""); + smsIntent.putExtra("sms_body",message); + context.startActivity(smsIntent); + } + + /** + * Send SMS + * @param context the context + * @param number number of the recipient + * @param message message that will intend to be sent as sms body + * */ + + public static void sendSMS(@NonNull Context context,@NonNull String number,@NonNull String message) + { + Intent smsIntent = new Intent(android.content.Intent.ACTION_VIEW); + smsIntent.setType("vnd.android-dir/mms-sms"); + smsIntent.putExtra("address",number); + smsIntent.putExtra("sms_body",message); + context.startActivity(smsIntent); + } } diff --git a/app/src/main/java/pavelpoley/com/socialutilshelper/MainActivity.java b/app/src/main/java/pavelpoley/com/socialutilshelper/MainActivity.java index b6b84ef..2b0cdbd 100644 --- a/app/src/main/java/pavelpoley/com/socialutilshelper/MainActivity.java +++ b/app/src/main/java/pavelpoley/com/socialutilshelper/MainActivity.java @@ -64,6 +64,8 @@ public boolean onNavigationItemSelected(MenuItem item) { } else if (id == R.id.nav_send) { SocialUtils.sendEmail(this,"pavelpoley88@gmail.com","Feedback"); + } else if (id == R.id.nav_sms) { + SocialUtils.sendSMS(this,"Hi! I am using this App"); } DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); diff --git a/app/src/main/res/drawable/ic_menu_sms.xml b/app/src/main/res/drawable/ic_menu_sms.xml new file mode 100644 index 0000000..8b8ead2 --- /dev/null +++ b/app/src/main/res/drawable/ic_menu_sms.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/menu/activity_main_drawer.xml b/app/src/main/res/menu/activity_main_drawer.xml index 7b8f464..9fe36a2 100644 --- a/app/src/main/res/menu/activity_main_drawer.xml +++ b/app/src/main/res/menu/activity_main_drawer.xml @@ -35,6 +35,10 @@ android:id="@+id/nav_send" android:icon="@drawable/ic_menu_send" android:title="Email" /> +