TechHui

Hawaii's Science, Technology and New Media Community

Sam Joseph's Friends

Sam Joseph's Groups

Sam Joseph's Discussions

Honolulu Coders Support Sprout

Started Feb. 28, 2008

Programmer wanted for Web 2.0 and Augmented Reality programming
1 Reply

Started this discussion. Last reply by Nic Rioux Aug 25.

My tech blog

Android Permissions and Audio

Found a list of all possible permissions:

http://developer.android.com/reference/android/Manifest.permission.html

would be nice if when you were trying to do something without permission it would tell you which one was missing.

Given that the example MediaRecorder code in the Android docs didn't work I was forced to search the Google Android Group for tips, and found this post with code that worked.

The challenge was then to see if the sound was being stored and I eventually found that it was when I pulled the sound file off Android with (of course I had to get the eclipse emulator to load the relevant sdcard by adjusting the launch configuration first):

./adb pull /sdcard/test.3gpp test.mp3

again the emulator seems to be available for attachment randomly ... usually the following returns nothing:

samuel-josephs-computer-2:tools samueljoseph$ ./adb devicesList of devices attachedemulator-5554    device

I did find a good summary of SD Card creation for Android.  The next challenge was to load the sound file back from the file system in order to play it, and I worked out how to store the file in the applications file space rather than within the sd card.  I am now storing the file in a sub-directory of the application space and reloading in an activity context like this (excluding all the exception handling):

String filename = "test.3gpp";File dir = this.getDir("sounds", MODE_WORLD_READABLE);File file = new File(dir, filename);
FileInputStream is = new FileInputStream(file);
MediaPlayer mMediaPlayer = new MediaPlayer();
mMediaPlayer.setDataSource(fileDescriptor);
mMediaPlayer.prepare();
mMediaPlayer.start();

So that was pleasantly simple.Continue

Android Multipart upload

So there were many posts about multipart upload in the Android Google Groups:
One guy rolled his own using HttpURLConnection, and another which strangely relied on dependencies from two different versions of the Apache HttpClient project (commons-httpclient.jar an httpcomponents-client-4.0-alpha4.); since version 3 of Apache's HttpClient was still a commons project, and the latter dependency is a version 4 alpha.  The sample code contained no import statements, so it was difficult to know which version of the library was being used for what.

My confusion was deepened when I found a discussion in an Apache forum suggesting that the multipart support had not been included in the move from version 3 to version 4.  There was yet another Google Groups discussion on the multipart upload using a different set of Apache libraries.  I also found a discussion of the relative merits of using HttpClient versus UrlConnection in Android.  I had heard before that some people have experienced odd issues with UrlConnection, which is why I switched over to HttpClient a while back (actually using an AndroidHttpClient class from the zxing project).  It is not clear if the URLConnection issues have been resolved with latest code release.  Either which way it is somewhat confusing that while there is some of the Apache HttpClient code in Android by default, it is not all there, or at least some of the latest parts of the library are not.
I ended up downloading the latest version of the Android HttpClient library which appeared to be version 4 beta 2 and was pleasantly surprised to find a code sample for a multi-part upload, despite the suggestion I had found that multi-part uploads had not been ported into this version.  I modified this example slightly for Android and I was even more pleasantly surprised when it worked (abridged code below):

  HttpClient client = new DefaultHttpClient();  HttpPost post = new HttpPost("http://api.whatever.com/something");
  FileBody bin = new FileBody(file);
  StringBody media_entity_part = new StringBody(media_entity);

  MultipartEntity reqEntity = new MultipartEntity();
  reqEntity.addPart("bin", bin);
  reqEntity.addPart("media_entity", media_entity_part);
  post.setEntity(reqEntity);

  HttpResponse response = client.execute(post);
  HttpEntity resEntity = response.getEntity();
  if (resEntity != null) {
    resEntity.consumeContent();
  }

The dependencies I had were the jar files that came with the latest HttpClient download:

apache-mime4j-0.5.jar
httpclient-4.0-beta2.jar
httpcore-4.0-beta3.jar
httpmime-4.0-beta2.jar

Of course I may have some overlap there too, but when it starts working you don't ask questions - at least while there doesn't seem to be a critical space issue for my android project at present.

Two feelings I come away with are:

1. Is the StringBody, FileBody class really necessary? Couldn't we just have reqEntity.addFilePart and reqEntity.addStringPart and avoid the extra line and class definitions? Seems like that just doesn't need to be seen by the API user.
2. The discussion of all this multi-part upload stuff is really scattered over the google groups for Android. I can't help but think they might get better convergence if the discussion was organised about the API itself, e.g. that questions about multi-part uploads all appeared linked with the Android docs: http://developer.android.com/reference/org/apache/http/client/HttpClient.html
MySQL, PHP and others have great embedded discussions in their docs - I don't know why Java and Ruby projects can't have similar ...Continue
 

Sam Joseph's Page

Latest Activity

yesterday
For all things related to coding
on Friday
Hey everyone, I just uploaded an album of photos to AquacultureHub of our initial Aquaponics build from the University of Hawaii Second Life. Work is still ongoing, but we do now have a fully connected Aquaponics farm based on Olomana Gardens in W...
on Thursday
Andy Sabo joined Sam Joseph's group
For all things related to coding
November 8
For all things related to coding
November 4
For hackers of ruby on rails
November 4
Hey all, I'm teaching a mobile programming course at HPU in the Spring. Will focus on iPhone and Android. Here's the link to sign up for single courses at HPU if you're not already enrolled there: http://www.hpu.edu/index.cfm?contentID=373 Check...
November 2
Featured Topics: Mobile News, Mobile Blogs, Mobi News,Top Mobile News Stories, Mobile Advertising, Mobile Marketing, Mobile Technology, Mobile Devices,Cell Phones, Android, M-Commerce, Mobile Commerce, Mobile Billing, Mobile Devices, WiMax, Wi-Fi.
November 2

Profile Information

Occupation:
Other
Software Language Proficiencies / Interests:
C, HTML, Java, Javascript, PHP, Python, Ruby, SQL, XML
Website:
http://www.linklens.org

Sam Joseph's Photos

Loading…

Sam Joseph's Blog

Sam Joseph

Honolulu Coders meeting - Kevin Hughes on Sprout - Wed 6pm

Sprout CTO Kevin Hughes shares the lessons his team has learned in building a Flex-based, Powerpoint-type application. He'll discuss software architecture decisions, what makes a superior Flex developer, and notes on working with combinations of Flash, Java, Ruby, and PHP in a startup environment.

Kevin Hughes is an internationally-recognized pioneer in Web design and software, having made imagemap, which allowed Web images to be interactive, and contributions to the Cascading Style Sheets stan… Continue

Posted on February 21, 2008 at 6:43am — 1 Comment

Sam Joseph

Rich GUI tools: RIA with Flex & Silverlight, Jan 30th(Wed) talk by Dan Leuck of Ikayzo.com

This month's Honolulu Coders meeting will take place on Wednesday 30th
January from 6pm to 8pm.



Dan Leuck of Ikayzo.com will talk about Flex and Silverlight, exciting rich client technologies that
facilitate the creation of, as Romain Guy would say, filthy rich UIs.
During this presentation Dan will create a simple photo management
application using both technologies, and discuss the pros and cons of
each platform.


Honolulu-coders mailing list:
Continue

Posted on January 16, 2008 at 9:48pm —

Sam Joseph

Collective Intelligence and iPhone LinkLens

Join us at Honolulu coders Wednesday night this week in POST 302 at UH Manoa:

http://tech.groups.yahoo.com/group/honolulu-coders/


I'll be talking about the new O'Reilly book "Collective Intelligence" by Toby Segaran, as well as showing off my new iPhone LinkLens application.


Posted on December 12, 2007 at 11:03am — 1 Comment

Comment Wall (7 comments)

You need to be a member of TechHui to add comments!

Join this Ning Network

At 2:17pm on November 29, 2009, John Wang said…
Hi Sam,

Question about your class. It has a few pre-reqs.
Pre-requisites: CSCI 2911, CSCI 2912, and CSCI 3401

I haven't quite gone through what they all are yet, but I'm wondering if they are still "required" for Special Status Students and how all that works out.
At 4:03pm on September 16, 2009, Daniel Leuck said…
Best of luck with the Android contest!
At 12:46pm on July 1, 2009, Monir said…
Hi Sam, How are you? I just referred a colleague to you regarding a question on Rails. I also joined your hackers group and hope to learn more on this topic. I am working on course material to teach Ruby on Rails. Please let me know of any good online resources you might have.
At 11:52am on April 14, 2009, 808blogger said…
http://wiki.secondlife.com/wiki/LlHTTPRequest

http://wiki.secondlife.com/wiki/Secure_HTTP_Post

combine this with some server side stuff and you can pull data into and push data out of SL
At 2:56pm on April 2, 2009, David C. Brauer said…
Hi Sam,

I've been visiting Virtual Manoa and have come up with a few questions.

1) Are there currently only two buildings? POST and Holmes. Does only the LILT lab have content?
2) How do I put up a PowerPoint poster like you have?
3) How do I put up a Web page poster like you have for Diane?
4) How do I put up my twitter status like Aaron and Phil?

That's all for now.

Thanks,

Dave
At 9:53pm on January 16, 2008, Daniel Leuck said…
Given your interest in natural language learning tools you might be interested in this blog post about Gabe Morris's Yabla website. Its an impressive web app.
At 11:48am on December 7, 2007, Daniel Leuck said…
E Komo Mai! The more I use this platform, the more I am impressed.

I'm definitely going to try deploying some custom features, possibly using the OpenSocial API.

BTW - Feel free to invite others :-) This only becomes interesting when we hit a certain critical mass.
 
 

Sponsors


web design, web development, localization

 

© 2009   Created by Daniel Leuck

Badges  |  Report an Issue  |  Privacy  |  Terms of Service