The Blog

Write an SMS without sending it on Android 2.2 Froyo

12 Ago 10

I just figured out how to write an sms without sending it really on android froyo 2.2 using the content provider.

I’ll write only the snippet here. Hope it helps

[sourcecode language=”java”]
* writes an sms on the contentprovider
* @param ctx Context
* @param mobNo mobile number
* @param msg text of the message
private final static void storeMessage(Context ctx,String mobNo, String msg) {
ContentValues values = new ContentValues();
values.put("address", mobNo);
values.put("body", msg);
ctx.getContentResolver().insert(Uri.parse("content://sms/sent"), values);

Obviously you should set the right permissions on the manifest ( Yes the following are all needed for this task ) :

[sourcecode language=”xml”]
<uses-permission android:name="android.permission.WRITE_SMS"></uses-permission>
<uses-permission android:name="android.permission.READ_SMS"></uses-permission>

Add Events on Google Calendar on Android Froyo and above

09 Ago 10

Since i started developing applications for android i noticed there were some undocumented apis. Google does reccomend to not use these apis but since there are no “other nice ways” to achieve some tasks sometimes they are useful ( but still unreccomended)

It’s the case of the Google Calendar Apis. Out there you can find a lot of docs about these undocumented & unsupported apis but you’ll get some troubles if google decides to change them.

For example if you want to add an “event” to the calendar programmatically you can follow the snippet below which is SDK proof. In fact i did ( It’s not refactored for better reading ) write some code that would work on Sdk from 1.5 to 2.2 ( aka Froyo ) solving the provider issue on froyo and above.

Hope it helps to solve the problem about google calendar in froyo :)

Reference to the CP: Xda