Skip to main content

Posts

Screen capture and save to SDCard in Blackberry Java (OS4.3 and above)

Blackberry OS (4.3 and above) provides a very easy way to capture screen of device. We can use screenshot(Bitmap bmp) method of Display class. In this post you will see how to capture screen contents and save to a file on SDCard. First we will get width and height of screen. This is very important because Bitmap we pass to screenshot method must have same width and height as of screen. int screenWidth=Display.getWidth(); int screenHeight=Display.getHeight(); Next, create a Bitmap object of dimensions equivalent to width and height of screen. Bitmap bmpScreen=new Bitmap(screenWidth,screenHeight); Take screenshot using screenshot method of Display class Dispaly.screenshot(bmpScreen); Now bmpScreen contains our screen image data. Our next task is to save this data in a file on SDCard. Let's create PNGEncodedImage from this Bitmap. PNGEncodedImage imgToSave=PNGEncodedImage.encode(bmpScreen); Open a file to write this image FileConnection fc=(FileConnection)Connector...

zipalign tool not found in SDK - Eclipse

While exporting Android signed application package through Eclipse you get this warning The zipalign tool was not found in the SDK. Please update to the latest SDK and re-export your application or run zipalign manually After getting this warning I started looking for zipalign tool. After searching in SDK folder I found zipalign.exe under copy_tools folder. This folder is used by Android SDK update to keep copy of old tools. What is zipalign tool ? From Android documentation zipalign is an archive alignment tool that provides important optimization to Android application (.apk) files. The purpose is to ensure that all uncompressed data starts with a particular alignment relative to the start of the file. How to make Eclipse find this zipalign tool To make eclipse use this zipalign.exe you have to copy it in a proper SDK folder. You can find SDK folder in %android-sdk-path% / build_tools / {sdkfolder} After copying zipalign.exe to this folder when you run Eclipse to s...

Resizing image in Blackberry 10 Cascades

In this post we will learn how to re-size an image stored on file or in memory. Cascades provide Image class to perform loading of images but it do not have any support for manipulating the image especially re-sizing of image. But we have a class QImage from Qt that support re-sizing of images. So first lets see how we can load image through QImage class Loading image QImage has many overloaded constructors for loading images from different sources or just create an empty QImage of given height and width. We will cover two constructors here, one for loading image from file and other to load image from image data in memory. Loading from file We will use a constructor that takes file name (QString) as a parameter. We can optionally pass format as a char* parameter but its better to skip that so QImage will detect format from the filename QImage img("asset:///testimage.jpg"); Loading from in memory data QImage provides another constructor to load image data stored ...

How to change JVM for Eclipse

I have following JDKs installed 1) JDK7 64 bit 2) JDK6 64 bit 3) JDK6 32 bit Also I have multiple Eclipse installed. They run on different JVM. For example Eclipse for Blackberry runs on 32 bit JDK and Eclipse for Android runs on 64 bit JDK. You can put only one JDK to PATH in Environment variable or JAVA_HOME environment variable. To configure Eclipse to use specific JVM you have to modify configuration file for your eclipse (usually eclipse.ini). Add following lines just before the line which says “-vmargs”. -vm D:\TOOLS\Java\JDK6-32bit\bin\javaw.exe {this should be the path to your desired JDK bin\javaw.exe }

15 Mistakes to Avoid When Traveling Solo (IndependentTraveler.com)

This blog posts contain excerpts from advice given by Ed Hewitt on IndependentTraveler.com  . View original article here What hostels and guesthouses are great for is meeting other folks doing the same thing that you are -- true fellow travelers. But you don't have to commit to them unrelentingly; your choice of lodging is just another tool in your solo traveler bag. When in need of comfort, safety and convenience, choose a reputable hotel; when in need of companionship, think about hostels and other alternative lodging options. Don't feel obligated to stay in hostels. On these nights, take it easy on yourself; you might stay near the airport or train station, or splurge on a well-known hotel, or take a cab when you might otherwise save money by taking public transit. Don't get too ambitious at the beginning or end of a trip. Having no money in your pocket and no way to get any is a problem for any traveler, but even more so when traveling solo.  Don...

Implementing OAuth2 consumer in C#

Recently I worked on a project that involved integrating with social networking and jobs websites like Elance. These days almost all major services that allow applications to access users' data, perform authorization/authentication using OAuth1.0 or OAuth2. OAuth2 compared to OAuth1 is very easy to implement. OAuth1 involves generating nonce,timestamp,signaturebase and signing the request with any algorithm like HMAC-SHA1 and appending data to query string of URL and passing in Authorization header of HTTP. OAuth2 removed all these requirements. Following is OAuth2 process in a nutshell 1) Redirect user to Authorization url passing client_id and redirect_url in query parameters 2) If user authenticates successfully through service provider it will redirect user to the redirect_url passed with authorization access code in query parameters. 3) After getting authorization access code you exchange this to receive access token. You make a POST HTTP request to a URL passing client_id ...

JEE File Upload - Handling Multipart requests in Servlets 3.0

Prior to Servlets 3.0 developers have to use 3rd party libraries to process complex multipart request that is sent when file is uploaded by user. Starting from Servlets 3.0 JEE provides a better way to handle file uploads (multipart requests) without using any 3rd party library. Making your Servlet ready to handle Multipart requests All you have to do is to add  @MultipartConfig annotation on your servlet class and it is ready to handle Multipart requests. @MultipartConfig   public class FileUploadServlet extends HttpServlet { Our example HTML form <form method="POST" enctype=" multipart/form-data "> <input type="file" name="ufile" /> <input type="submit" value="Submit" /> </form> Handling the POST in processRequest method of Servlet protected void processRequest (HttpServletRequest request,         HttpServletResponse response)         throws ServletException, IOException { Gettin...