Android | Set SMS Body?

666 views
Skip to first unread message

Henry

unread,
Mar 12, 2011, 10:18:45 PM3/12/11
to phonegap
Hello,

Does anyone know if you can create a new SMS AND pass text for the
body? I know the sms uri will create a new sms and you can pass a
recipient phone number - but I don't believe you can pass text for the
body? Anyone have any info on this?

I don't need the app to send the sms on it's own, just open the sms
app with pre-filled recipient and body info and the user can press the
send button.

Any ideas? I've searched around and can't find any answers :(

Thanks!

Dezső Róbert

unread,
Mar 13, 2011, 5:09:12 AM3/13/11
to phon...@googlegroups.com
Hi,
I have the same problem and tried different URIs on different phone without any success. I think simply you can't set the message body. I I think the only solution is to write a plugin in JAVA that sends an SMS.

Robert

2011/3/13 Henry <henry...@gmail.com>
--
You received this message because you are subscribed to the Google
Groups "phonegap" group.
To post to this group, send email to phon...@googlegroups.com
To unsubscribe from this group, send email to
phonegap+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/phonegap?hl=en?hl=en

For more info on PhoneGap or to download the code go to www.phonegap.com

Henry

unread,
Mar 13, 2011, 5:16:04 AM3/13/11
to phonegap
I think I may have a solution, but it will require me to edit
droidgap.java , I not know how to do that. It seems later version of
phonegap uses classes? And those are compiled files? Any idea how to
edit those? I hope I can try my solution and share it with everyone.

On Mar 13, 1:09 am, Dezső Róbert <drobee...@gmail.com> wrote:
> Hi,
> I have the same problem and tried different URIs on different phone without
> any success. I think simply you can't set the message body. I I think the
> only solution is to write a plugin in JAVA that sends an SMS.
>
> Robert
>
> 2011/3/13 Henry <henryle...@gmail.com>

Joe McCann

unread,
Mar 13, 2011, 12:59:09 PM3/13/11
to phonegap
You'll need to create a custom URI and register it's intent in the
manifest. Essentially you'll need to "override" the default SMS://
scheme and create your own like

mysms://

Then, you'll most likely need to create the JavaScript bridge to
manage this intent resolution. Sounds possible, but definitely not
trivial.

Henry Levak

unread,
Mar 13, 2011, 1:10:52 PM3/13/11
to phon...@googlegroups.com
This is exactly what I'm going to take a stab at. I wanted to modify
the existing override.. Where do I do this?I was thinking
droidgap.class but don't don't think I can there..

Henry Levak

unread,
Mar 13, 2011, 3:34:12 PM3/13/11
to phon...@googlegroups.com
Here is what I was thinking.. in DroidGap.java  PhoneGap already overriders the sms uri..
// If sms:5551212
            else if (url.startsWith("sms:")) {
             try {
             Intent intent = new Intent(Intent.ACTION_VIEW);
             intent.setData(Uri.parse(url));
             intent.putExtra("address", url.substring(4));
             intent.setType("vnd.android-dir/mms-sms");
             startActivity(intent);
             } catch (android.content.ActivityNotFoundException e) {
             System.out.println("Error sending sms "+url+":"+ e.toString());
             }
             return true;
            }


If I could just change the "intent.putExtra("address", url.substring(4));" to
"intent.putExtra("sms_body", url.substring(4));"

I think that may work? You wouldn't be able to put a recipient address there but you could fill in the body.
Clearly I'm not an Android developer, so maybe this is a waste of time - but I can't figure out how to even try this.


Bryce Curtis

unread,
Mar 13, 2011, 11:39:57 PM3/13/11
to phonegap
Henry,

Thanks for pointing out this problem. It has been fixed in commit
https://github.com/phonegap/phonegap-android/commit/7344964c05cdaa3598eaf72de68ceb8157241d7f
and will be in 0.9.5. You can specify an sms message by using the uri
"sms:#?body=The message".

Thanks,
Bryce

On Mar 13, 2:34 pm, Henry Levak <henryle...@gmail.com> wrote:
> Here is what I was thinking.. in DroidGap.java  PhoneGap already overriders
> the sms uri..
>
> // If sms:5551212
>             else if (url.startsWith("sms:")) {
>                 try {
>                         Intent intent = new Intent(Intent.ACTION_VIEW);
>                         intent.setData(Uri.parse(url));
>                         intent.putExtra("address", url.substring(4));
>                         intent.setType("vnd.android-dir/mms-sms");
>                         startActivity(intent);
>                 } catch (android.content.ActivityNotFoundException e) {
>                         System.out.println("Error sending sms "+url+":"+ e.toString());
>                 }
>                 return true;
>             }  
>
> If I could just change the "intent.putExtra("address", url.substring(4));" to
> "intent.putExtra("sms_body", url.substring(4));"
>
> I think that may work? You wouldn't be able to put a recipient address
> there but you could fill in the body.
> Clearly I'm not an Android developer, so maybe this is a waste of time
> - but I can't figure out how to even try this.
>
>
>
>
>
>
>
> On Sun, Mar 13, 2011 at 10:10 AM, Henry Levak <henryle...@gmail.com> wrote:
> > This is exactly what I'm going to take a stab at. I wanted to modify
> > the existing override..  Where do I do this?I was thinking
> > droidgap.class but don't don't think I can there..
>

@neavilag (Norman)

unread,
Mar 14, 2011, 12:13:39 AM3/14/11
to phon...@googlegroups.com
Great, how or what we have to do to get the update? sorry new to PG and was looking for this, will this apply to BB and Iphone ??

Henry Levak

unread,
Mar 14, 2011, 1:08:47 AM3/14/11
to phon...@googlegroups.com
So cool, thanks Joe and Bryce!

Bryce Curtis

unread,
Mar 15, 2011, 11:39:02 AM3/15/11
to phonegap
Norman,

To get this fix, you will need to download source from github - or
wait until 0.9.5 is available in about a month.

I will have to check with others to see if this already works
correctly on BB and iOS. If not a ticket will be opened to fix (if
possible).

Regards,
Bryce

On Mar 14, 12:08 am, Henry Levak <henryle...@gmail.com> wrote:
> So cool, thanks Joe and Bryce!
>
> On Sun, Mar 13, 2011 at 8:39 PM, Bryce Curtis <curtis.br...@gmail.com>wrote:
>
>
>
>
>
>
>
> > Henry,
>
> > Thanks for pointing out this problem.  It has been fixed in commit
>
> >https://github.com/phonegap/phonegap-android/commit/7344964c05cdaa359...

Norman E. Avila G.

unread,
Mar 15, 2011, 11:56:40 AM3/15/11
to phon...@googlegroups.com
Thanks for your information.

--
Norman E. Avila G.
-------------------------------
USA +1 412 ClimaYa
+1 412 254-6292
GUA +502 2360-9950

Reply all
Reply to author
Forward
0 new messages