Mobile/Photo/J2ME Blogging with PersonalBlog.
Well
I finished another chunck of mobile blogging functionality. I wasn't
satisfied with merely posting from my mobile phone. My Sanyo 8100 has a
built-on camera, and I want to include pictures taken from my phone in
my mobile posts. However the Sanyo 8100's J2ME implementation doesn't
allow a midlet to access any of the camera functions.
Since the camera can send pictures via email, I decided to explore
the alternative of sending emails to my weblog. So I created a new
email account just for my weblog. I added some new code to PersonalBlog
for reading any emails in the the email account's inbox. I didn't want
to waste to much time studying the java api for accessing emails, so I
borrowed snippets of email processing code from Moblogger. (I hope you don't mind Russ.) Things were going well, but Sprint PCS threw me a curveball.
When a Sprint PCS subscriber sends a photo taken with a camera
phone, the email doesn't include the photo in an email attachment.
Instead you actually get a html email which contains an image tag that
references an image stored on Sprint's website. So I needed to write
some code that would parse the email to find the url of the image. I
haven't had much experience doing this, but I figured it out.
Once I had the image URL, I wrote some more code using the java's
ImageIO library that copied the JPG images from Sprint to my weblog.
Since I wanted to preview the pictures from PersonalBlog Mobility on my
mobile phone, I had to also write some code that would create PNG
thumbnails because the J2ME implementation only can process PNG images.
I think the CLDC only supports PNG images, but I'm not sure. Prior to
this excercise I have never worked directly with the ImageIO library.
This was another learning experience for me.
Next I added an additional service to PersonalBlog (using XML-RPC)
that returns a list of images that were processed by PersonalBlog from
emails sent by my phone.
Keep in mind that all the changes I've made so far have been to
PersonalBlog (the Struts/Hibernate-based web application proudly built
using JAVA). At this point no changes have been made to PersonalBlog
Mobility (the J2ME midlet). With the changes to PersonalBlog complete,
I was ready to embark on the changes to PersonalBlog Mobility.
PersonalBlog Mobility already had the ability to post entries to a PersonalBlog instance.
I augmented it to retrieve the image list from PersonalBlog (via
XML-RPC). When creating a new post from a mobile phone, I added a
checkbox that indicates whether you want to include a picture taken
with the phone. If so, you can scroll through the list of images. As
you scroll up/down the list, the Mobility will show you a preview of
the picture by retrieving the associated thumbnail (PNG) from
PersonalBlog via HTTP. Once you select an image to be included in the
mobile post, the original JPG image (not the PNG preview) is appended
to the post.
Once you have added a title, selected one or more categories,
selected a picture, and written the post, the post is submitted to
PersonalBlog. Here is a weblog entry that was submitted from my Sanyo 8100.
This makes it very easy to include pictures taken with my
camera-phone in my mobile posts. All I have to do is (1) Take picture
with phone, (2) Send it to weblog email address, (3) Preview/Select the
image using PersonalBlog Mobility. It literally takes less than a
minute.
[
java.blogs Day's Entries]