Saving a message as Draft (far from easy!) - Android Software Development

I'm trying to save a message ad draft. I know, its an undocumented API, but it would be nice to see the messaging in any application.
Here is the code
Code:
Uri drafts= Uri.parse("content://sms/draft");
values = new ContentValues();
values.put("body", "Draft Body");
values.put("type",3);
values.put("address","+1234567890");
long date = System.currentTimeMillis()-60000; //just to test
values.put("date", date - date % 1000);
values.put("read", 1);
//values.put("status", -1);
//values.put("seen", 0);
//values.put("modified", 1);
contentResolver.insert(drafts, values);
I'm testing on android 2.2 froyo and the message get saved but in the standard messaging application no label "Draft" is shown. as you try to reply you get a message with the same address but empty body. Now, when pressing the return button and you get back to the conversation list the message disappear.
-- in my LG Optimous One the type get changed to MMS, date is set to 1/jan/1970 and CANNOT BE DELETED!
-- in the emulator the message simply gets deleted.
I tried other apps for testing and none was successful in saving a draft on my phone: (ChompSMS, [SMSdroid], Handcent SMS, GO SMS). The draft they save is seen in the standard application but the same problem applies when opening the standar application.
-- In Android 2.1 using the emulator everything works like a charm!
I'm really unpleased to see that basic messaging functionalities are so problematic and NOT OFFICIALY SUPPORTED in Android.
Anyone experienced similar problems? Did you managed to solve this issue?
Best Regards,
Marco

Related

Read SMS

Hello!
I have some difficulties to read SMS in my application : my application doesn't want to use the fonction SmsOpen in mode RECEIVE. Do you know the parameters to use in this function to read Sms?
Gremlins (and I'm not Gizmo!)
funny as Gizmo asked me exact the same question via private mail ...
This was my response:
----------------------------------------
I've never used the function to read SMS messages but here is my suggestion:
check the return code of SmsOpen, it is probably SMS_E_RECEIVEHANDLEALREADYOPEN. According the SDK help it means, that another app has already opened and is using the provider. In most cases, that might be Inbox, so shut down the Inbox task befor you are running your code.
If your error code is different, check the meaning in the help file, look for SmsOpen -> SMS specific error codes.
You don't have disable Inbox. The problem is the internal SMS handler - if you look in \Windows\Startup, you'll see a SMSHandler (I don't have a T-Mobile at the moment, so can't confirm the exact name). You need to get your application to start before it. In addition, you need to do a SmsSetMessageNotification() for both SMS_MSGTYPE_RAW as well as SMS_MSGTYPE_TEXT message types. Strangely, the code does not get the notification if you only set it for one of the two.
I have a T-Mobile MDA. There is a folder called "AutoStart" in the Windows folder, so I guess the file called "SMSReceiver.exe" is the handler you were talking about. I named my application "aaamyapplication" in order to start it up first after a soft reset (There is actually no "startup" registry-entry either for "SMSReceiver" nor for my application... in the end I kicked "SMSReceiver" out).
Unfortunately receiving an SMS through my app does not work (but strangely the system is still able to receive SMS in spite of deleting "SMSReceiver").
Do you have a good guess what I should do? I would be grateful for any advice
t_lex
Could some body be more specific on what Jvd said ??? i'm running an XDA2 and when i look in windows/startup i only get the followng :
CheckAutoRun
ChgDfLnk
IA_Caller_ID
MMReg
poutlook
stk
wifiIcon

Scripting a text message for London Congestion Charge

Hi there,
Is it possible (or could any kind developper!) to script a text message that would always have the same text.
Basically to pay the London Congestion Charge (£5 for driving into Central London), one needs to send a text message to the number 81099 containing the last four digits of their credit card.
As the message is always the same, I thought it might be easy to script such a message to make it easy to pay the charge.
Thanks!
isn't that easy? set up your pre set messages as the words and numbers u need so then u create a new text and click my text chose the one u want and send it!
Hi,
Thanks for your reply. I see what you mean, but that is still several clicks more than I have in mind. With a script/batch file, it would literally be a one button (through a shortcut) click which could even be assigned to a hardware button. Lazy ... maybe! I guess it all really depends on whether the function to send a text message can be accessed from the command line.
no kidding ur lazy!
You can write smssender.html which will include a javascript, that will redirect you to:
mailto:123456789 body="Send me a taxi!" - I'm not sure about the syntax...
Everytime you execute this webpage, you will only have to confirm SMS sending and close IE (I don't know if window-terminating scripts work in PocketIE) :idea:
(!)
I don't know if you're willing to pay for it, but there is a utility called Cell Profiler found here
You can pre-define an SMS to be sent to a particular number when you drive through a particular point.
Download the trial and see if it fits in with your requirements.
You can use the scripting utility called nscriptm to automate your screen taps etc. Give it a go. Its fairly simple and there is a good sample that shows you how to work with screen taps.
Thanks for your replies. I will try each and see what works best for me.
Thanks again!
XDA2-owner said:
Hi there,
Is it possible (or could any kind developper!) to script a text message that would always have the same text.
Basically to pay the London Congestion Charge (£5 for driving into Central London), one needs to send a text message to the number 81099 containing the last four digits of their credit card.
As the message is always the same, I thought it might be easy to script such a message to make it easy to pay the charge.
Thanks!
Click to expand...
Click to collapse
I wonder if I understand you correctly. In my SMS messaging on the XDAII I have something called My Text as a menychoise. The predefined messages in there can be added/amended in the Edit menu...You could do it easily there...?
Hi,
Yeah - someone mentioned that earlier. What I was really looking for though was a literally one-button way to pay my congestion charge - basically a shortcut to a batch-file/script that creates the SMS, enters the text and addresses it correctly.
Does anyone know if the mailto: command that you can use to create an e-mail would work for an SMS? If so, that would be fine as within the mailto: command you can specify the recipient (81099 in this case) and the text (credit card digits).
Thanks for all the responses.
1. PPCs don't make any difference between e-mails and short messages - you have same dialog, same options and same mailto: command...
2. JavaScript in HTML page is probably the fastest way to perform actions you need (if you dont want to write it in C++ of coz!)
3. If I'm not too drunk today I'll have probably posted an example of such page by tomorrow - I finished with school today, so I have something to celebrate! 8)
Would be great to see a javascript sample if you could be bothered/sober enough to put one together.
Thanks very much indeed.
So, that's what it looks like:
<html><body>
<script language="JavaScript">
window.location="mailto:81099?body=Here's my creditcard number!"
</script>
</body></html>
mailto: - where
body: - what
You can also add subject: (don't forget to divide it with "?" :!: )
It looks like Pocket IE does not support close() function. Can anyone confirm? Any way, even if you will have to close IE manually, executing this file (possibly from Today screen) and pressing SEND is still faster than going to New>SMS>MyText>choose>enter number>confirm... 8)
That worked just great! Thank you so much.
I used the PHM Pocket PC PowerToys's TrayLaunch program to put a shortcut to the .htm file onto the bottom bar of the Today screen.
I still need to press the Send button (is there a way to automate that?) and close IE but it's still MUCH quicker than doing it through a manual SMS.
Thanks again for all comments and help.
Compose new text message from shortcut
Hi there,
I'm a total newbie (NOT a programmer at all), just a Qtek 9090 addict. I 've been looking for something similar to your request: I wanted a way to go straight to the "compose text message" window from the today screen or a hardware button. I finally found a way to do this (maybe not the best way, but I can't find a site that lists all the possible parameters for tmail.exe).
If you're still looking for a better way to automatically launch your message, try this:
Copy the "Messaging" shortcut from Windows/Start Menu and put the copy somewhere you can work on it. Rename it to something like "London Congestion".
If you have Resco file explorer on your device, select your new shortcut and view its properties. On the second tab ("shortcut"), you should see the line "\Windows\tmail.exe". Change it to this:
"\Windows\tmail.exe" -service "text" -to "81099" -body "your credit card number"
Then tap "ok".
Move your new shortcut to Windows/Start Menu/Programs. Now you should be able to access it with your Today screen launcher or Button launcher.
If you don't have Resco file explorer, copy your shortcut to your desktop and open it with Notepad. You'll see something like 43#"\Windows\tmail.exe"; just leave the number at the front, make the adjustments I described and save the file. Then put it in Windows/Start Menu/Programs on your device.
I tested this and it worked for me, so I hope it does for you too!
To simply go to the "compose" window from a shortcut, I use this line:
"\Windows\tmail.exe" -service "text" -to ""
Robrecht.
Thanks a lot Robrecht,
I was actually going to re-open this issue because I have a Blueangel now - and I don't know if it's because it is WM2003 Second Edition or not, but the javascript that was written for me in the above post no longer works, so I needed a new method.
A very timely reply and I will try it over the weekend.
Thanks a lot,
Jimmy
I think you should add "I hope it chokes you bunch of rip off bastards" We pay road tax, we pay huge tax on fuel, we sit for hours in jams and they want money :?:
Well, XDA2-owner, you're very welcome!!!
I have a Blue Angel too and it works for me, except....... I discovered a flaw.
I thought the
-service "text"
parameter made sure the automatically created message was always a text (SMS) message, but instead it turns out that the format of the new message (SMS, e-mail, MMS...) changes according to the last viewed folder in Pocket Outlook. So if you were checking your e-mail account just before you use my shortcut, it wil create an e-mail instead of a text message.
This sucks! And I was so happy I'd been able to help someone!
Does anyone know a way to make sure the new message is always a text message?
Hi again,
This issue was one I was also having with the Javascript - I got used to the fact that if I was using the e-mail part of Messaging, I would switch it back to SMS before closing it.
One issue I am having though - and it might just be to do with my setup - is that when I run the shortcut from Start-->Programs-->Congestion, it works fine. When I try and launch it from my Today screen though, using BatteryPackPro, it doesn't seem to create the text message, and just stays on the Today screen.
Any ideas?
Thanks again for your help and ideas.

Sprint MMS Block Workaround [Idea for Developers]

If you haven't already heard Sprint has denied access to the MMS service with PPC devices. We used to get around this by installing Arcsoft MMS but even that won't work anymore.
Since the only way to send MMS or PictureMail is through E-Mail I was wondering if it's possible to develop an application to make this an easier process. The application will ask for phone number or contact name, the carrier, the media to be sent, the subject, and the message. With all that information it'll compose an e-mail to [phonenumber]@[carrier'saddress].com
-- Edit --
no2chem is working on a workaround. see his post on ppcgeeks from more info.
http://forum.ppcgeeks.com/showthread.php?t=19122
A simple workaround...is to send the pic to urself...([email protected]) and once u receive it jus forward the url to people u wanna send it to. thaz wut they get anyway. that way you dont have to worry about different carrier mms addresses.
Others have a working MMS application installed through their carriers or none PPC Sprint phones. The beauty of MMS is the fact that it's so simple to send and retrieve the media. If it wasn't for that then we can just e-mail each other photos and skip the whole process.
this sounds like a great idea, until sprint lets us use it again, which i don't see happening
malibu_23 said:
A simple workaround...is to send the pic to urself...([email protected]) and once u receive it jus forward the url to people u wanna send it to. thaz wut they get anyway. that way you dont have to worry about different carrier mms addresses.
Click to expand...
Click to collapse
When you say send the pic to your self at [email protected] I am assuming you mean to your 10 digit phone #@sprint.pm.com
I sent a pic to myself via hotmail and I get the message returned to me...how did you do this?
you have the address wrong.
it's [email protected][B]pm.sprint.com[/B]
initial said:
you have the address wrong.
it's [email protected][B]pm.sprint.com[/B]
Click to expand...
Click to collapse
meh, im thinking about working on this. but believe me, i have a looooot of other things on my hands.
wouldn't be that hard though, a simple app where it just asks you the photo/audio/video you want to send and the destination number... and whisks it away....
no2chem said:
meh, im thinking about working on this. but believe me, i have a looooot of other things on my hands.
wouldn't be that hard though, a simple app where it just asks you the photo/audio/video you want to send and the destination number... and whisks it away....
Click to expand...
Click to collapse
Actually thats funny, because I have been working on this lol. Building the DB right now still. Do you happen to know of any third party MMS applications? Open source or the API's?
what language are you writing it in.. I would be more then Happy to help with the dev work.
I better start preparing to bow down to you guys if you crack this
fr0st said:
what language are you writing it in.. I would be more then Happy to help with the dev work.
Click to expand...
Click to collapse
Visual Basic
i developed a beta workaround,
see
http://forum.ppcgeeks.com/showthread.php?p=192013#post192013
COUNT ME IN.. I would rather c# but I would love to help. My roommate and I both are programmers and would love to assist? You looking for some help blue?
do you have any problems with sharing your code (which I am sure in in c++) no2chem
fr0st said:
do you have any problems with sharing your code (which I am sure in in c++) no2chem
Click to expand...
Click to collapse
Frost be more then happy. As I told u in pm my last post is still pending it will shed some nfo on this. NU said he wrote in C++ not sure if he is willing to help. As far as I go I haven't wrote C in 7yrs never took on ++ though there not far off.
NUC - I will go check out what you have.
Someone posted this
Someone over on the PPCGeeks forum posted this site:
http://pktpix.com/
Seems like it might be a workaround as well as no2chem's... Just like teleflip and other SMS Gateways, but this one is international (and free)...
fr0st said:
do you have any problems with sharing your code (which I am sure in in c++) no2chem
Click to expand...
Click to collapse
no problems really, but the code is very simple and is in c#...
c++ would have been too much time...
this code does nearly all the work...
OutlookSession os = new OutlookSession();
EmailAccount ea = os.EmailAccounts[0];
EmailMessage em = new EmailMessage();
em.BodyText = textBox1.Text;
em.To.Add(new Recipient(textBox2.Text + "@" + ((carrier)comboBox1.Items[comboBox1.SelectedIndex]).address));
em.Importance = Importance.Normal;
em.Sensitivity = Sensitivity.Normal;
if (imagename != null)
{
em.Attachments.Add(new Attachment(imagename));
}
ea.Send(em);
mapi.setAccountName(ea.Name);
if (mapi.forceSyncbyName())
{
MessageBox.Show("Message Sent");
}
else
{
MessageBox.Show("Forcing sync failed, message is in your outbox.");
}
Visual Basic, I could use help new to developing on a PPC platform.
This is the function. The idea is to build a small DB because most people only have a small group of people they MMS. Easily containable in a personal config. A DB of all the carriers MMS addresses on file where users also configure a parameter of numaric class carriers with exceptions for ported numbers. Look a little like this to give you a basic idea. Like local zone 850-532-XXXX = ATT and 850-543-XXX = Sprint.
User adds contact in send list. App verify value as.
Load contact in string as send_to but we will only load first 7 chars
Open DB config file
Load DB config file
If send_to is = to a char value in config we auto address sending address as textBox.Text = string_to + carrier match
Else
Prompt string carrier_db user selects a carrier from list load to string usr_carrier
Then textBox.Text = send_to + user_carrier
Write send_to+usr_carrier to DB config
call Send_btn
EndIf
Obviously more then 1 IF statement is needed lol just a concept idea so you know what I am doing. As well an exempt file is needed for ported numbers to reference before the DB carrier file is called. Then if number is not listed we can call an ElseIf statement to carry onto the above. The grab contacts reference is also still needed.
no2chem said:
no problems really, but the code is very simple and is in c#...
c++ would have been too much time...
this code does nearly all the work...
OutlookSession os = new OutlookSession();
EmailAccount ea = os.EmailAccounts[0];
EmailMessage em = new EmailMessage();
em.BodyText = textBox1.Text;
em.To.Add(new Recipient(textBox2.Text + "@" + ((carrier)comboBox1.Items[comboBox1.SelectedIndex]).address));
em.Importance = Importance.Normal;
em.Sensitivity = Sensitivity.Normal;
if (imagename != null)
{
em.Attachments.Add(new Attachment(imagename));
}
ea.Send(em);
mapi.setAccountName(ea.Name);
if (mapi.forceSyncbyName())
{
MessageBox.Show("Message Sent");
}
else
{
MessageBox.Show("Forcing sync failed, message is in your outbox.");
}
Click to expand...
Click to collapse
"EmailAccount ea = os.EmailAccounts[0];" So you change the 0 to whatever number the email account on your phone is right? 0 being outlook... and i'm guessing an autonumber from then on?
Also what namespaces and assembly references are you using?
fr0st said:
"EmailAccount ea = os.EmailAccounts[0];" So you change the 0 to whatever number the email account on your phone is right? 0 being outlook... and i'm guessing an autonumber from then on?
Also what namespaces and assembly references are you using?
Click to expand...
Click to collapse
well, that was code for the quick beta.
Microsoft.Windowsmobile namespace, look into it =) its quite nice.
EmailAccounts[0] would pick the first e-mail account, it only can use e-mail accounts in outlook. i used[0] as a quick hack and slash test, but now i let them choose which e-mail they want to use, , you would just enumerate thorugh all the email accounts,
foreach (EmailAccount ea in os.EmailAccounts)
{
....
}

SMS sent confirmation

One thing I miss about my old phone is the "sms sent" confirmation I used to get after sending a message. (also with a little animation).
It's really annoying to have to go round the houses to get to the sent folder to see if a message has been sent or not.
I had a whole day with a load of messages unknowingly sat in the outbox thinking they'd been sent which really annoyed me. It was only after I checked at the end of the day I found out they hadn't
Does such a thing exist for the diamond or is it too dependant on windows mobile.
Also still have not found a decent lock program that locks EVERY button (including the power) and stops me answering calls getting my phone out my pocket and the sleeve. Tied s2u2 and touchlockpro but they are still unreliable
What was wrong with "menu - star" like on the nokias. - Worked a treat !!!
Any help would be appreciated
ROM Dutty 3.1 WWE
Radio 1.0.25.16
Alright mate.
Can't help with the locking problem, but here's what you need to do to get notification of SMS sent...
Go to the "messages" tab in TouchFlo and click "all messages". Then click "menu", "tools" and "options". Click "* SMS\MMS" and make sure "Request delivery notifications" is checked.
I don't use this myself, but I just tested it and it works for me.
Hope this helps you out.
John.
I use the following tip:
Use any Registry Editor, such as freeware CeRegEditor or PHM Registry Editor, and navigate to the following registry key:
HKEY_LOCAL_MACHINE\Software\Microsoft\Inbox\Settings\
If “Settings” branch does not exist, create a New Key with name as Settings. Then highlight Settings, and then create a new String Value key with value name as SMSNoSentMsg, with its value data as 1.
phreaq said:
I use the following tip:
Use any Registry Editor, such as freeware CeRegEditor or PHM Registry Editor, and navigate to the following registry key:
HKEY_LOCAL_MACHINE\Software\Microsoft\Inbox\Settings\
If “Settings” branch does not exist, create a New Key with name as Settings. Then highlight Settings, and then create a new String Value key with value name as SMSNoSentMsg, with its value data as 1.
Click to expand...
Click to collapse
... you're nearly right. You need to set the value to '0' if you wish to receive a notification that the SMS has been sent. If you set it to '1', you will not receive the notification (this is the default).
Nice one thanks guys. Went for the reg edit as didn't fancy getting a text back from operator every time I send one.
Just for the record yes the value of "SMSNoSentMsg" needs to be 0.
Again cheers for your help
Resurrecting this thread
I discovered this one earlier today, so far I'm liking it.
SMS Retry Notification
Enables/Disables a notification when an SMS message failed to be delivered. The phone will display a Popup displaying a summary of the message, to whom it was sent and when, and ask if you would like to try again.
[HKCU\ControlPanel\PhoneExtendFunction\CDMA] change PhoneExt_SmsRetry
0 - Disable (Default)
1 - Enable
My phone is a Sprint CDMA phone (hence the registry address) but hopefully it's not a Sprint setting and other CDMA phones and maybe GSM phones have a similar location.
Retry Notification
smotrs said:
I discovered this one earlier today, so far I'm liking it.
SMS Retry Notification
Enables/Disables a notification when an SMS message failed to be delivered. The phone will display a Popup displaying a summary of the message, to whom it was sent and when, and ask if you would like to try again.
[HKCU\ControlPanel\PhoneExtendFunction\CDMA] change PhoneExt_SmsRetry
0 - Disable (Default)
1 - Enable
My phone is a Sprint CDMA phone (hence the registry address) but hopefully it's not a Sprint setting and other CDMA phones and maybe GSM phones have a similar location.
Click to expand...
Click to collapse
Sweet. I also like the original setting in this thread. I like to know when my text is sent. I don't use text that ofte, s this is not an inconvenience to me.

[Q/WIP/Need Help] Mass Text by Push of a Button

I am creating an application where it will send a pre-prepared text to selected people at a push of a button. The reason for this is that I am a volunteer firefighter and most of us have pagers. Some of us do not have pagers since the department ran out and they are not in the budget to buy more right now.
Anyways, I have the basic layout that I would like set up.... And that's about it. I am used to javascript but that is a little different then Java. I am using the Eclipse program to code.
Here's my priorities to get working first:
-Have a message sent when button is pushed (message can be hard coded now so it works. would like to be able to edit it later)
-Be able to select contacts the message is sent to
Future wishes:
-Be able to add new messages
-Be able to edit messages
-Manage messages (mainly a list of the messages in scrollable list view)(popup for Edit|Delete)
Example Message:
(DEPT NAME) Alert:
Fire Alarm Activation
Time sent: 1830
Click to expand...
Click to collapse
So right now I need help with:
Adding the SMS service to send out the text message when the button is pressed
Selecting contacts to send the message to
Coding in the message
If you can find a guide on how to do that, it would be greatly appreciated. I am completely new to android programming so please don't bash me for something that may seem completely easy.
Thanks in advance for any help.
Probably a free app out there.
Why not just make a Contact with multiple phone numbers in it and create the text using default SMS app? If speed is of the essence, then pre-define some "codes" for certain events much like on a pager where you get a "911" from a caller.
And don't take this the wrong way because I know a few volunteers and appreciate their service because it is NOT "easy", but a PAGER? Haven't they gone the way of the floppy disk? LOL That's a damn tight budget there!
I have looked and haven't seen one that will fit my needs.
Speed is essence in this case because i want to be able to open up the app and then hit a button to send the text so I am not fiddling with my phone while driving to the station.
I have the basics of the program worked out. I have all the messages pre-set and sendable, but only to one person.
(for those looking for a guide on how to implement SMS messaging, this is a great one that shows you step by step: http://mobiforge.com/developing/story/sms-messaging-android)
I am now stuck on being able to send it to multiple people at the same time. Current code:
callStructureFire.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String msgText = "IHBVFD PAGE OUT:\nStructure Fire\nTimeout:"+formattedTime;
String contacts = "5556";
sendSMS(contacts, msgText);
}
});
Click to expand...
Click to collapse
(Red is where the numbers go. I am using Eclipses emulator's to test so i have 5554(main) 5556 and 5558 (testing for receiving messages))
When I try to do "String contacts = "5556, 5558(with and without the space)";", it will send the message to the first phone but not the second. On a real phone, it does not send the messages at all.
I also still need to implement a contact selection which I have been looking on google for a few hours now and cant find a guide on how to do it. What I would like to happen is when you press the phones menu button, it gives the option to manage the recipients (or even a group) and for that selection to stick even if I leave the app/restart the phone/whatever.
I really would like to get this all done by Thursday night so I can start using it.
No offense taken. The thing is that my department is strictly volunteer. We get about 100 calls a year so we do not have the call volume to get paid. Being strictly volunteer also means the the city does not charge taxes to the residents. We are really only funded by donations and fundraisers (which we do 2-3 a month). With pagers (Minitor IV) being around $140+ on ebay and then $30-50 for programming them... Yeah... It gets kinda pricy for 4 pagers lol.
Can anyone help me get multiple contacts working at least? Really want to have this done soon.
Skull, I am guessing your Communications center does not support any type of email or txt ripnruns for calls?
If either are supported, we use IamResponding.com and also CADPage (free on the market). Our center only sends emails but we have it getting parsed down to a compact format and resent as TXT. PM me if you want/need more info.
I cannot speak enough about both of these solutions!
Our dispatcher is our police dept. We have recently talked about IAmResponding within the dept but that got shot down by the officers because that's an extra 3-800 a year... And again, not everyone has pagers so they still wouldn't really know if we have a call. I am still trying to get them to do the 2 month trial. CADpage isn't supported in my county.
We have looked into those, but for now this program is the only option that I can see :/

Categories

Resources