0

my app need's to send data to another android device so far its sending it through sms messages that gets blocked in the other android device ... but since the kitkat version i cant block them anymore.. is there anyway of sending push messages in the background to another user and receiving them back ? and if so... I would love to see any example ( I don't prefer GCM i think its way too complicated.. ) .

this is the code i am using to send the SMS message :

SmsManager sm = SmsManager.getDefault();
ArrayList<String> parts =sm.divideMessage(String.valueOf(points));
int numParts = parts.size();
ArrayList<PendingIntent> sentIntents = new ArrayList<PendingIntent>();
ArrayList<PendingIntent> deliveryIntents = new ArrayList<PendingIntent>();
 for (int i = 0; i < numParts; i++) {
    sentIntents.add(PendingIntent.getBroadcast(getBaseContext(), 0, getIntent(), 0));
    // deliveryIntents.add(PendingIntent.getBroadcast(getBaseContext(), 0, data, 0));
 }

 sm.sendMultipartTextMessage(number,null, parts, sentIntents, deliveryIntents);
 SmsManager.getDefault().sendTextMessage(number, null, String.valueOf(points), null, null); 
                        }

Looking for something similar just for the push messages.

Vamshi
  • 1,495
  • 1
  • 15
  • 31
mynavy
  • 81
  • 2
  • 9

2 Answers2

1

Google Cloud Messaging is what your are after:

http://developer.android.com/google/gcm/index.html

One disadvantage over your current method is that you will probably need a server to act as a broker, as a GCM message can only have a relatively small payload

CurlyPaul
  • 1,138
  • 1
  • 10
  • 29
  • Well my message shouldnt be that big but I dont have a problem to limit the string that im sending... Is ther anything else besides GCM ? I cant understand how to implement that . – mynavy May 13 '14 at 10:40
  • That's fine but if you don't go with the GCM notification then you have left other choice, create a WebService for your functionality and go ahead. – GovindRathod May 13 '14 at 10:51
1

You could send a data SMS. They operate differently than a regular SMS because they use a port upon sending, and so you specify that same port on the receivers handset. This avoids the problem of competing intent filter priority on the SMS receiver.

This allows direct sending from one android to another.

See here for an example

Community
  • 1
  • 1
Shane
  • 150
  • 6
  • that sounds interesting from the example i can see that the other user when receiving the message He can see it actually or not ? In my case I prefer he wont see that message... – mynavy May 13 '14 at 11:04
  • Amazing.. its working... no need for any Abort broadcastReceiver... the message is short but Very usefull ! Thanks alot – mynavy May 13 '14 at 11:45
  • 1
    yeah the user won't see the message. Its pretty good isn't it, this has saved me before too - happy to pay it forward – Shane May 13 '14 at 11:55