Last active
April 1, 2017 08:29
-
-
Save JMGama/e93a81b19e8f5562b6221eee47795de9 to your computer and use it in GitHub Desktop.
Send SMS from an Android device
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void sendSMS() { | |
/*SEND SMS FROM AN ANDROID PHONE*/ | |
checkSMSStatePermission(); | |
String phone = "4455877998"; | |
String text = "Hellow im sending this SMS from my app"; | |
SmsManager sms = SmsManager.getDefault(); | |
sms.sendTextMessage(phone, null, text, null, null); | |
} | |
private void checkSMSStatePermission() { | |
int permissionCheck = ContextCompat.checkSelfPermission( | |
this, Manifest.permission.SEND_SMS); | |
if (permissionCheck != PackageManager.PERMISSION_GRANTED) { | |
Log.i("Message", "You do not have permission to send SMS!"); | |
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.SEND_SMS}, 225); | |
} else { | |
Log.i("Message", "You have permission to send SMS!"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is how you can send a message from an android phone in your APK.