I have an application which requires sending sms from one user to another.On receiving this sms it sends back a reply sms.I have developed a code but the problem is it goes in aloop of sending again and again from one user to another.For example if user 1 sends some sms to user 2,then a sms is automatically sent to user 1 which in turn automatically sends sms to user 2 again and this goes again and again.How can I avoid that? I have to send the reply sms only once from user 2 to user 1 and then no return sms.Please help me with this code.
Here is my code:
http://pastebin.com/rt2Dd20k
Thanks in advance.
If you know the exact text that the automated SMS reply will contain, can't you just put a condition around the block that sends the reply?
String autoReplyText = "Whats up";
boolean isAutoReply = msgs[i].getMessageBody().toString().equals(autoReplyText);
if (!isAutoReply) {
sms.sendTextMessage(str2, null, autoReplyText, pi, null);
}
edit: if the message is dynamic (which it seems that it needs to be, based on your comments) then you could ensure that all automatic replies start with a special string token which identifies them as an automatic reply. This way, if you receive a message that starts with your token, you know you don't need to reply:
String autoReplyToken = "[BANANA]";
String autoReplyText = autoReplyToken + " dynamic message content";
boolean isAutoReply = msgs[i].getMessageBody().toString().startsWith(autoReplyToken);
if (!isAutoReply) {
sms.sendTextMessage(str2, null, autoReplyText, pi, null);
}
Related
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 very new to java server side development, i have followed this link [http://javapapers.com/android/google-cloud-messaging-gcm-for-android-and-push-notifications/][1] and successfully implemented GCM with my android device, the problem is dont know how to trigger the GCM server while the content is updated in my db,i need to notify each and every update of my db to the user, am i need to watch the db using timer task something like that or is there any default solution to keep track of db ?
My Server side code :
regId = "my registration id";
String userMessage = request.getParameter("message");
Sender sender = new Sender(GOOGLE_SERVER_KEY);
Message message = new Message.Builder().timeToLive(30)
.delayWhileIdle(true).addData(MESSAGE_KEY, userMessage).build();
result = sender.send(message, regId, 1);
have tried with many solution but till now not getting exact solution, Suggestion, ideas or related links are most welcome
Thanks in advance
Without knowing the specific functionality of your server and app, I can only offer a general solution.
Each process in your server that performs DB updates that have to be pushed to some Android devices via GCM can write the messages and the registration IDs to some kind of queue.
Then you can have another process (or processes) that would consume the queue of GCM messages, and send them to Google. These processes can handle failures (retry sending the messages in case of temporary failures), and update your database of registration IDs if they receive responses with canonical registration IDs or errors such as InvalidRegistration or NotRegistered.
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 a text messaging app that I want users to be able to text another app of mine on someone else's phone that will show up within the app. Printed on screen. I have one app that will send the message and one app on the receiving device that will display the message. How would I go about doing this?
The receiving app is an opengl app that will display the message in front of a 3d model from the sending app.
If someone could help me out or get me going in the right direction, I would greatly appreciate it. Thank you for your time.
EDIT: This is what I'm doing. I'm making a live wallpaper that women can put on their phone, a seperate "regular" app will allow the husband, fiance, etc to send a message to the lwp on the significant others phone that will display at the top half of the lwp screen.
public void sendSMS(String phoneNumber, String message)
{
PendingIntent sentPI = PendingIntent.getBroadcast(this, 0,
new Intent(SENT), 0);
PendingIntent deliveredPI = PendingIntent.getBroadcast(this, 0,
new Intent(DELIVERED), 0);
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(phoneNumber, null, message, sentPI, deliveredPI);
}
You can do something like this for sending the sms.
Yes, it's possible.
Use SMSPopup as a working Android project you can use. It has the two parts you need: the sending part and the receiving part, and it's open source. Here it is on Google Play.
The only issue is that the user probably won't want those application messages intermingled with his normal SMS messages.
So you'll want to tag your application text messages with a unique keyword so that the receiving app knows it's a message for itself and no one else. And by tagging, I just mean to insert a unique keyword at the beginning of its subject line.
And your receiving app will have to register a BroadcastReceiver with a priority of 100 so that if it detects a message intended for itself, it can just delete it from the content provider and just do an AbortBroadcast so that the other text messaging apps don't beep for a message that wasn't meant for them in the first place.
In that sense, SMSPopup probably already does 90% of what you need. SMSPopup doesn't automatically delete the sms it receives, nor will it filter them on a particular keyword, but it must silently swallow them so that the normal notification system for sms doesn't get triggered (since SMSPopup provides its own notification popup interface instead).
Hi Steve we have RabbitMQServer to send messages between apps. We should configure the server and need to implement functionlities to send and receiving messages.
You may get details about RabbitMQ server at http://www.rabbitmq.com/.
want to develop an app that can automatically respond to a received text, include my location using gps/google maps in the returned message, and read out the received message using text to speech.
My first concern (what this question relates too!) is figuring out howto automatically reply to sms messages received. I have built a basic GUI and menu option. There is an EditText field that uses shared_preferences to remember the string so far.
How do I go about adding this string to an sms message, and making the messege send to whomever just texted me? I have a decent understanding of java but I havn't been about to find any clear examples and an a bit confused.
Any help would be great!
Thanks
(Basically a java oracle version of the app inventor application "NoTextWhileDriving2")
For an android specific solution you can use the SmsManager class. Here is some example code taken from a similar question that deals with sending an sms message from an android application.
Have a look at SmsMessagingDemo from the android development API demo page. Below is a snippet of the sending code.
// Watch for send button clicks and send text messages.
Button sendButton = (Button) findViewById(R.id.sms_send_message);
sendButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
if (TextUtils.isEmpty(recipientTextEdit.getText())) {
Toast.makeText(SmsMessagingDemo.this, "Please enter a message recipient.",
Toast.LENGTH_SHORT).show();
return;
}
if (TextUtils.isEmpty(contentTextEdit.getText())) {
Toast.makeText(SmsMessagingDemo.this, "Please enter a message body.",
Toast.LENGTH_SHORT).show();
return;
}
recipientTextEdit.setEnabled(false);
contentTextEdit.setEnabled(false);
SmsManager sms = SmsManager.getDefault();
List<String> messages = sms.divideMessage(contentTextEdit.getText().toString());
String recipient = recipientTextEdit.getText().toString();
for (String message : messages) {
sms.sendTextMessage(recipient, null, message, PendingIntent.getBroadcast(
SmsMessagingDemo.this, 0, new Intent(ACTION_SMS_SENT), 0), null);
}
}
});
You have to setup a BroadcastReceiver for receiving of SMS messages. Very nicely described in Android Developers Blog.
There is also an open source application working with SMS on code.google.com android-smspopup.