I declared these two variables in order to send a text message to declared number:
private String text="Hi";
private String emergencyNum="00962789113300";
Then in onCreat() method I wrote this:
SmsManager sender= SmsManager.getDefault();
sender.sendTextMessage(emergencyNum, null, text, null, null);
Unfortunately, the message was not sent and I got not responding status for my app. Could you help me to solve the problem.
Please place the following permission into AndroidManifest.xml file.
<uses-permission android:name="android.permission.SEND_SMS"/>
Related
Is there any way to send sms using SmsManager without open the App.
I am using FirebaseMessagingService and i got remoteMessage from onMessageReceived method its Contains Mobile No and Message.
Then i am sending SMS using using SmsManager. and also i declared permission.SEND_SMS/RECEIVE_SMS in manifest file.
This is My Code:
public void onMessageReceived(RemoteMessage remoteMessage){
String mobile = remoteMessage.getData().get("mobileno");
String message = remoteMessage.getData().get("message");
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(mobile, null, message, null, null);
}
Its Working on when App is Running. but not working on when app is not running in background.
Is there any way to SEND sms when App is not running.??
Please help me.. Thanks...
Finally i got answer from firebase console. i did some mistake in Nodejs Server code after corrected that code its working fine...
I recently made an app which could send messages using the android smsManager api, and was wondering if there is a way to send a sms message through the an android api where the id of the sender is spoofed.
this is the current state of the code I used which sends the message to my cell:
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(recipient, scAdress, msg, null, null);
I've tried to edit the scAddress, but the message doesnt send (I was seeing if that would work, and wasn't sure what scAdress was)
I am also aware that I could use a site like Twilio or Tropo, but I want to send the message through the sim card, not over the internet.
I know you are interested in doing this on your current SIM via other means. Sorry I can't be of more help there. However, this does sound like a fun way to play with Twilio Wireless. You should check out the documentation here.
I am currently using
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(phoneNumber, null, message, null, null);
to send sms messages from an android phone. However it always goes immediately into the phone's sent box ("content://sms/sent") is there away to send sms messsages without it going into the sent box?
P.S. I know how to delete messages from the sent box but that requires waiting for about a second before it is stored in the box.
I have been trying to remove all the logs on the device through this code:
contentResolver.delete(CallLog.Calls.CONTENT_URI,null,null);
But it only deletes Call Logs, and SMS logs still remain undeleted.
How delete all the logs including SMS logs?
Any help would be appreciated..!!
getContext().getContentResolver().delete(
Uri.parse("content://sms/conversations/" + threadID),
null,
null);
try this
You can remove all smslog using this way.
getContentResolver().delete(Uri.parse("content://sms/"),null,null);
for Deleting SMS from your smslog need uses permission declared in your manifest
<uses-permission android:name="android.permission.READ_SMS"/>
<uses-permission android:name="android.permission.WRITE_SMS"/>
I've got a BroadcastReceiver that handles the android.provider.Telephony.SMS_RECEIVED action, and sends a text message as a reply in certain cases. My app has the android.permission.SEND_SMS, and works fine on GSM phones. However, it doesn't work on the only CDMA phone I have available to me at the moment, and I suspect it only occurs on CDMA phones. It works on all of the GSM phones I have tried, which are quite a few. logcat shows no errors nor warnings, only D/SMSSMSSMSSMS( 260): TeleService: 4098 each time sendSms is called. Furthermore, I have tried the exact same code in an Activity, and it works perfectly fine.
The code I'm using:
private void sendSms(String destination, String message) {
if(preferencesManager.smsRepliesEnabled()) {
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(destination, null, message, null, null);
}
}
preferencesManager.smsRepliesEnabled() works as expected, and destination and message are set properly. I added a Log.d statement to confirm all three of these. Likewise, PhoneNumberUtils.isWellFormedSmsAddress(destination) returns true.
EDIT: On the advice of #wojci I added a sentIntent and logged the result code. The result code is RESULT_ERROR_GENERIC_FAILURE, with the extra errorCode set to -1. When I try the exact same code from an Activity, however, it works fine with RESULT_OK.
You write that you use the following to send a text:
smsManager.sendTextMessage(destination, null, message, null, null);
Why are you not using the sentIntent parameter which can tell you if your message was accepted by the network?
From the documentation:
sentIntent if not NULL this PendingIntent is broadcast when the message is successfully sent, or failed. The result code will be Activity.RESULT_OK for success, or one of these errors:
RESULT_ERROR_GENERIC_FAILURE
RESULT_ERROR_RADIO_OFF
RESULT_ERROR_NULL_PDU
Maybe it can give you some more clues as to why your SMS sending does not work as you expect it to.