Slashdot Mirror


Pro Java ME MMAPI

Cory Foy writes "Several months ago Vikram Goyal emailed me letting me know he had a new book coming out from Apress, Pro Java ME MMAPI: Mobile Media API for Java Micro Edition. Having done mobile device development using J2ME, I knew how difficult it can be to do, or explain, some of the tricks in device development. So I wanted to see if this book could rise up to the challenge." Read below for the rest of Cory's review. Pro Java ME MMAPI author Vikram Goyal pages 250 publisher Apress rating 8 reviewer Cory Foy ISBN 1590596390 summary A clear guide for implementing J2ME on your phone

I've noticed as of late that the quality of the technical books I've been reading has deteriorated. Misspellings, wrong calculations, grammatical errors, not the thing to inspire confidence in the subject. In addition, the content can be hard to follow, it's hard to grasp where the author is going, etc, etc.

Not this book. I was immediately struck in the first chapter by how clearly written the book is. Yes, you need to have some knowledge of J2ME device development (specifically MIDlets), but Vikram does a great job easing you in to the subject, and providing good, easy to follow examples.

The subjects he is covering, dealing with media on mobile devices (specifically phones) is a particularly tricky subject. The problem? Many device manufacturers implement standards differently. They claim to support things they don't. They ignore features you would expect. Worse, their emulators, the very thing you develop against, don't always match the phone. In fact, very rarely do they match the phone.

Vikram tackles this by testing his code on several different types of devices, and clearly lists out the dangers of relying on just the spec, or the reference implementation, or the emulator. I've seen versions of the same phone work differently based on what the provider had done to the phone. Verizon will always be evil to me based on my experiences of porting code that worked great on Nextel to Verizon phones, but that's another story.


Chapter 2 provides an overview of the basics of the MMAPI. In particular, how to get data from a DataSource to play in a Player. Since the MMAPI is designed to be implemented by device manufacturers, it is a great read to see how an API can remain simple, yet cover a vast array of inputs and outputs. For example, Player instances can read files, streams, web sites, and a variety of other inputs. It can control audio, video, MIDI and tones. All of this using the same underlying API. Pretty good stuff.

Chapter 3 gets us diving into some code. We write a basic multimedia player, and then improve it to add functionality and increase performance by understanding what is involved in caching Players.

Chapter 4 continues on explaining the more about the underlying architecture, specifically the media player lifecycle and events. Since we are dealing with devices that generally have limited resources, the API provide a way to save claiming those resources until as late as possible. In addition, it provides ways to reclaim those resources, and Vikram covers some of those ways in this chapter. He then moves on to discuss the eventing architecture, and how to respond to custom events (he does briefly describe writing your own events but I can attest that getting anything that low level on a device from US providers is usually pretty difficult).

It wouldn't be a good programming book if we didn't talk about threads at some point, and Vikram touches on it in Chapter 5. Specifically, we're diving into accessing files over the network, and we don't want to block the device while we are doing that. Yes, when you are running a MIDlet, the app thread is the main phone thread, so if it is waiting for network traffic, the phone is unresponsive to the user. So very wise use of threads is necessary. In addition, some security considerations start coming into play, and the book covers what to expect.

Now the fun starts. In Chapter 6, the book discusses Tone Control, the first of 2 entertaining chapters on making your device make noise. The chapter starts off with a very concise explanation of basic music theory to give developers an understanding of what they are going to need to do to generate tones of different pitches. It then moves on to the difference between Mono and Polyphonic notes, and how to create sequences of notes. By the end of the chapter, you too can have your phone playing "Happy Birthday".

Chapter 7 continues on with the party, going into one of my favorite subjects, MIDI. Again, we get a good, concise introduction to the fundamentals of MIDI. We then get to see how to send raw messages to a device that understands MIDI, and how to use MIDI in the MMAPI.

Chapter 8 touches on the other aspect of media — Video. To do this, it first discusses sampled audio, and how to capture and control it. It then goes into capturing video, which many devices may not support, and how to capture snapshots for those devices with cameras. It also covers what to do with the file when you've captured it (for example, save it or display it to the user), and closes with a discussion on streaming media.

I was surprised when I got to chapter 9 because chapter 8 ended by saying what we were going to cover in the final chapter, and I hadn't realized that I had read that much already! Chapter 9 is a great way to end the book. Vikram shows us how to implement our own mobile blogging website, complete with implementing uploads for Text, Audio and Video (if our devices support it). He even provides screen shots and full code, walking through it step by step to help us understand what is going on.

All in all I very much enjoyed the book. If you have a phone capable or supporting J2ME, this is definitely worth a read. The writing is very clear, and entertaining. If there is a downside, it is the poor integration of J2ME in a lot of providers devices, and the inconsistencies in the implementations. But thankfully Vikram guides us through all that so we can quickly be up and running singing along to our favorite dance hit with the words on our phone, mobile blogging the whole thing.

You can purchase Pro Java ME MMAPI: Mobile Media API for Java Micro Edition from amazon.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.

20 comments

  1. Author's credentials? And too specialized? by perkr · · Score: 4, Interesting

    Great review. What would have made it even better IMO is if the author's credentials in creating mobile multimedia applications for actual clients were highlighted. Lately I have been disappointed by many books being written by authors who appear to never have actually participated in realistic projects in a corporate/open source setting. The book material in those cases tend to be rather shallow -- more like tutorials than books that can teach you something beyond all free (often great) documentation available on the web.

    A second thought that struck me is that the book sounds very specialized. I wonder how much content of this book that could go into a regular ME book. For instance, threading in order to not block the phone UI is not exactly rocket science... sounds to me there is a lot of filler material in the book.

    1. Re:Author's credentials? And too specialized? by Anonymous Coward · · Score: 0

      Google may come up with a framework based on J2ME? The GMAIL app on Mobile is pretty cool.

    2. Re:Author's credentials? And too specialized? by Anml4ixoye · · Score: 1

      Actually, there isn't a lot of filler (Disclosure: I'm the reviewed ;)). The book is pretty short, and a very fast read. I read it in about 2 hours on a trans-atlantic flight.

      The book is pretty specialized, and it probably would fit well into an ME book, but I think it fills a good niche if you are having to do these kinds of things.

      And, since the story is about to drop off the main screen, looks like this review will set a record for the lowest number of comments on a front-page story. ;)

  2. Read the book, get excited about what's possible by defile · · Score: 4, Interesting

    ...and start developing that great app for your mobile phone. Maybe you too have wondered why no one has developed that killer app, but gosh darnit, you'll just have to be the first!

    Soon you come to realize you weren't the first. The more you look, the more rotting corpses you find. Thousands have come before you and died. What the fuck?

    The sad realization finally sets in: the mobile industry is tightly locked up by manufacturer/carrier imposed DRM, and terms like "net neutrality" are just distant memories. They are the gatekeepers and they don't want just anybody playing inside of their garden.

    Run.

  3. new low in comments by Anonymous Coward · · Score: 0

    Is this a new low in comments on a /. front page submission or what? and i'm not new here...

    slow news month indeed

    1. Re:new low in comments by Greenisus · · Score: 1

      Maybe they're actually reading the article? No...that can't be it.

  4. RMAD (Rapid Mobile Application Development) by Rac3r5 · · Score: 1

    Hi,

    I am working at a company where we would like to actually enable users to view our charts and graphs on mobile devices with web connectivity. I have been looking into what the best way to deploy this is. We use chart director to develop our graphs/charts so that's not a problem. But rather how do we develop applications rapidly for use on any mobile with a web connection with/without java installed. What I want to implement is basically business intelligence on a mobile app. At a .NET conference I saw a demo where a small mobile application (no gui) was developed in a matter of 5 mins and it could be displayed on 5 different types of phones (non smart phones). What is the best way to go about this? At the root of it, I don't want the client to be dependent on any technology. But on the server side, I would prefer to stay with Java since most of our systems use RedHat.

    Thanks...

    1. Re:RMAD (Rapid Mobile Application Development) by ironfrost · · Score: 1

      But rather how do we develop applications rapidly for use on any mobile with a web connection with/without java installed

      I'd suggest dropping the "with/without java installed" requirement - it's an unnecessary handicap, because about 80% of mobile phones support Java ME and the ones that don't are almost all "voice and text only" devices that don't have internet access anyway. The only other solution that will get you reasonable compatibility is to view the charts with the inbuilt web browser.

  5. Re:Read the book, get excited about what's possibl by drinkypoo · · Score: 2, Insightful

    The sad realization finally sets in: the mobile industry is tightly locked up by manufacturer/carrier imposed DRM, and terms like "net neutrality" are just distant memories. They are the gatekeepers and they don't want just anybody playing inside of their garden.

    Frankly I don't think that's the most serious problem. I think the real issue is what the manufacturers do, or more to the point, don't do. For example, my RAZR V3i has a 1.2 MP camera. It would be great to be able to access it from Java. But Motorola failed to include any camera/video MMAPI support, so I can't even use the semacode reader.

    Many phones permit you to load MIDlets freely. But since phones implement different features, there's little point in apps not customized for phones.

    --
    "You're right," Fisheye says. "I should have set it on 'whip' or 'chop.'"
  6. Implementation problem by Anonymous Coward · · Score: 0

    Today I tried to play back a sequence of short .wav files (100 ms each). However the sound is very irregular. Some wave files terminate playing to soon, sometimes the break after one file and before the next one is to long. (Relying on the events that should get fired when a play back stops is not a good idea, it works for a 20s file, but not for the short ones.) I have this problem in the simulator as well as on an actual Nokia phone.

    Can anyone point out a (link to a) tutorial where they explain how to do this properly. If this question were answered in the book, I might consider buying it, but wanted to be sure.

    Thank you for your attention

    n01 (misplaced my password, again)

  7. Get netbeans, the mobility pack... by Anonymous Coward · · Score: 0

    a sprint phone and a web server with a fixed IP address. Sprint because
      I know you can download your own midlets if you want.

  8. wtf, DRM - what DRM? by Anonymous Coward · · Score: 0

    Some phones are locked into carrier's walled gardens, but not all by any means. Lots of phones will freely load java midlets over the mobile internet (if they have a data plan), or through computer to phone link, or by bluetooth, or via SD card. Things are moving pretty fast so there is a confusing mishmash of functionality and support - but you can do some fun lowest common denominator stuff.

    What is this DRM of which you speak? As far as I can tell if your phone is happy to install applets j2me provides nothing you can use to implement DRM. The key thing is that it looks like there is no way for a midlet to prove its identity, that it is not a re-engineered imposter mal-midlet, to a server it connects to. Correct me if I'm wrong but it looks like the best you can do is sign the midlet and hope no one reverse engineers the protocol it uses to talk to the server - is that really 'safe'?

    1. Re:wtf, DRM - what DRM? by Anonymous Coward · · Score: 0

      My Cingular phone is locked in this fashion. I can load/install any midlet I want, but if it tries to access any hardware or network, it pops up a question saying "allow/deny?". Every time. There's no "always allow" or even "allow for this session" or anything like that. The exception is midlets that are signed by Cingular's key. Those ones work just fine. I had to hunt down some ridiculous unlocking program so I could install Google Maps on my phone and have it actually be useable. So yes, I'd call that DRM, and I'd say it's locked down for any normal user that doesn't have some specialized program and knows where to find and how to edit the configuration files (with unix newlines, even though the unlock software is in windows, just for fun).

  9. maybe ... but Re:wtf, DRM - what DRM? by Anonymous Coward · · Score: 0

    I see what you are getting at, but ultimately as you say you downloaded some unlock prog that could undo all their no doubt painfully and expensively arrived at 'protection'. (btw if you had a ref that would be interesting as a buddy has some sprint sony phone that is locked down)

    They are restricting you to try to force you or developers to channel business through them (though they kind of sell that 'signing' of midlets as protecting you from unknown possibly dangerous code) and that really does suck. But really all they can do is slow things down, it only takes one fellow to make the unlocker and then here you are using google maps.

    But imagine you wanted to construct some 'CryptoIM' system using https to some server. You can download the midlet, decompile it, instrument it to squirt the cleartext somewhere, reinstall it (maybe you have to also unlock the phone as you did so its not so annoying/detectable but I think in principle you don't have to) and that phone now looks like it supports CryptoIM but it is bugged. Here the attack is really on the other CryptoIM users and the service itself. It just seems full of holes.

    1. Re:maybe ... but Re:wtf, DRM - what DRM? by Anonymous Coward · · Score: 0

      I'd love to go into more detail, but I won't since that would undoubtedly render me a circumvention device and I'd be tossed off a boat or something by the riaa gestapo. suffice to say that it only took me 2-3 days of searching to find the software, after following lots of broken links in forum posts to sites that had been shut down (recently, because the forum post wasn't that old)... once I got it running, (which, now that I'm recalling, required downloading some australian drivers as well, plus switching my phone into "engineering mode" using a special key sequence) it only took me a few minutes to update the file. mostly because I was following the forum posts, and because I already had cygwin installed (so the unix newlines weren't any problem)

      as far as the cryptoim case, yes, you'd definitely have to unlock the phone, because nobody would be fooled if they suddenly had to hit "accept/deny" every 2 seconds. Also, I think it might have been the case that only network access was set for accept/deny, and all other access was automatically denied.

      And, the best solution to the problem you mention is to allow the user to add trusted signing certificates if they enter their security passcode. Then everything is safe, and you never have to worry about untrusted sources forging the midlets you download. Best of all worlds. Almost as if pki was intended for that purpose ;)

  10. Also general loss of interest in the mobile Java by S3D · · Score: 1

    If to trust Google trends interest in J2ME is falling slowly. Seems even Windows mobile with it's miniscule market share doing better than J2ME. Google trends for J2ME vs WinMobile

  11. Re:Read the book, get excited about what's possibl by Builder · · Score: 1

    Move to Europe - we get to decide what apps we install on our phones :) I've never had a phone that I couldn't add an app to because of rights management / Operator control.

  12. I had read about this on another site. by Metropolisforever · · Score: 1

    The people on http://doom3.zoy.org/ are obsessed with books. ^_^