Archive

Archive for December, 2009

BlackBerry HTTP Connection Factory w/ inline support for multiple network type

December 18th, 2009 No comments

This Api supports various network type and failover and coverage checks on BlackBerry device.

http://www.versatilemonkey.com/HttpConnectionFactory.java

priority order:

public static final int DEFAULT_TRANSPORT_ORDER[] = { TRANSPORT_WIFI, TRANSPORT_BES, TRANSPORT_BIS,
TRANSPORT_DIRECT_TCP, TRANSPORT_WAP2 }

Sample use:

 
 HttpConnectionFactory factory =
  new HttpConnectionFactory( "http://www.versatilemonkey.com/test.txt",
       HttpConnectionFactory.TRANSPORT_WIFI | HttpConnectionFactory.TRANSPORT_BES );
 while( true ) {
    try {
       HttpConnection connection = factory.getNextConnection();
       try {
          connection.setRequestMethod( "POST" );
          connection.setRequestProperty( "Content-type",
                                          "application/x-www-form-urlencoded" );
          OutputStream os = connection.openOutputStream( );
          os.write( "foo=bar&var2=val2".getBytes() );
          os.close();
          InputStream is = connection.openInputStream();
          //do something with the input stream
          if( whatever we did worked ) {
             break;
          }
       }
       catch( IOException ) {
          // Log the error or store it for displaying to
          // the end user if no transports succeed
       }
    }
    catch( NoMoreTransportsException e ) {
       //There are no more transports to attempt
       Dialog.alert( "Unable to perform request" );
       //Note you should never attempt network activity on the event thread
       break;
    }
 }
 
 

JavaScript Bridge to Google Maps API for Flash

December 18th, 2009 No comments

When you want animated maps or zippier feedback than Google’s JavaScript mapping API can provide, you can use the Flash Maps API. Yes, even Google acknowledges that its popular, full-featured platform can’t do everything. Using the Flash API used to mean you needed to know Flash. Now, you can get the benefit, but still program in JavaScript.

Web developer Nianwei Liu has released a wrapper API for Flash Maps, called Map Bridge: