Skip to content

Commit

Permalink
Merge pull request #2 from AsadLeo14/master
Browse files Browse the repository at this point in the history
Add a function SendSMS
  • Loading branch information
pavelpoley authored Aug 30, 2018
2 parents 78d27c4 + 4ba38c2 commit e2539d0
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ public boolean onNavigationItemSelected(MenuItem item) {

} else if (id == R.id.nav_send) {
SocialUtils.sendEmail(this,"[email protected]","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);
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_menu_sms.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M20,2L4,2c-1.1,0 -1.99,0.9 -1.99,2L2,22l4,-4h14c1.1,0 2,-0.9 2,-2L22,4c0,-1.1 -0.9,-2 -2,-2zM9,11L7,11L7,9h2v2zM13,11h-2L11,9h2v2zM17,11h-2L15,9h2v2z"/>
</vector>
4 changes: 4 additions & 0 deletions app/src/main/res/menu/activity_main_drawer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
android:id="@+id/nav_send"
android:icon="@drawable/ic_menu_send"
android:title="Email" />
<item
android:id="@+id/nav_sms"
android:icon="@drawable/ic_menu_sms"
android:title="SMS" />
</menu>
</item>

Expand Down

0 comments on commit e2539d0

Please sign in to comment.