Program Resource

Resource libraries for programmers and developers

Installing Sony SmartWatch2 SDK and Building Sample Apps

Installing Sony SmartWatch2 SDK and Building Sample Apps

SDK is installed via Android SDK Manager. Detailed steps can be found in page below. http://developer.sonymobile.com/knowledge-base/sony-add-on-sdk/install-the-sony-add-on-sdk/ Add to path, and under Android 4.1.2, install “Sony Add-on SDK 2.0” (and/or later version). After installing, open File -> New -> Project, and select Android Sample Project. Select SmartExtensionAPI. And same for SmartExtensionUtils. Open project property for SmartExtensionAPI, and check Is Library. Open project property for SmartExtensionUtils and check Is Library, and click “Add” button and add SmartExtensionAPI. Then, select Sample project you want to try. In project property for sample project you selected, click “Add” button under Library and add SmartExtensionAPI and SmartExtensionUtils. Now, you are ready to build project, install to …

Pitfall for using uses-permission, writing manifest to increase supported devices

When creating Android app, uses-feature and uses-permission are used inside manifest, but this might cause unwanted filter-outs. In my app, I first had manifest as but since app was usable without camera, I’ve changed to as follows for request from user who wanted to use app with device  without camera. However, this didn’t list up app in Google Play. I had to write like this: Write uses-feature for camera, and add android:required=”false” parameter to clarify camera is not required. Android device with front-only camera device was also filtered in first 2 manifest code. Not only camera, location and bluetooth, which was part of function but not mandatory to app, was …

Get specified number of Tweets for specified user (v1.1 support)

Simple code to get specified user’s tweet in Android, v1.1 support. API has restriction, where tweet data can be fetched up to 15 times per 15 min from same IP. Reference: http://stackoverflow.com/questions/12916539/simplest-php-example-retrieving-user-timeline-with-twitter-api-version-1-1 Twitter4j library is used; download from site below and copy required jar file to your libs folder in project. Tweeter4j http://twitter4j.org/en/index.html Next, you need to get a access key. https://dev.twitter.com/apps Login, “Create a new application” and go to OAuth Settings to get your key. Copy paste your 4 keys to code, and you are done.

Get Title, duration, and thumbnail image from Youtube URL

Youtube movie information can be fetched in xml format. Using this info, you can get title, duration, and other data you want. Below is sample to get title/duration and thumbnail bitmap image. Code returns title and duration info in string. Code to get thumbnail image.

Go back and forth in WebView history with finger gesture

It is easy to add Web functionality to Android app using WebView. It is hard to customize contents shown inside webview, but you can customize UIs. This time, I’m going to show how to use gesture, swiping finger left / right to go back / forward in webview history. GestureDetector class is used for gesture processing. By using this class, not only left / right swipe but also double tap or long hold can be assigned to some functions. Be careful not to override too much of  browser functions. Use WebView class as base, and create custom WebView class to handle gesture. In sample code below, swiping finger left to …

Get/Set Wifi status in Android

Getting / setting Wifi in Android is easy. First, set permission in manifest. CHANGE_WIFI_STATE is not needed when only getting status. Now, simple code. Since Wifi status changes realtime, register BroadcastReceiver if you want to get notified if status changes.

Get specified number of Tweets for specified user (Simple ver)

(June 12, 2013) Due to end of service, code below no longer works. Easy code to get specific user’s tweet. This API has a restriction, that max number of API calls allowed from same IP is limited to 150 times per hour. Therefore, users who share global IP will easily result in 400 (Bad Request). May be usable for personal use.

Handle stylus, eraser, and pressure with supported device (Android 4.0 support)

Device like Samsung Galaxy Note, some Android device supports stylus input. Those stylus uses Electro-Magnetic Resonance technology, and able to distinguish stylus and finger, and also provides pressure info, and some pen supports eraser mode. If you have stylus supported device, you can try Stylus Tester for Android to see what kind of data it gives (as 05/07/2013, app is not Android 4.0 ready). It isn’t hard for app to support stylus; you just need to add some flag checker in onTouchEvent function. Below is simple sample code. For android after 4.0, e.getToolType is used to check stylus, and e.getMetaState for older android version. Build.VERSION.SDK_INT is used to check OS version. e.getToolType …

Read/Write multi QR code using Zxing Part3 : Writing QR

Writing out structured array QR code, in my case, pages of QR code was fixed to 4 and data size per code was fixed, so I didn’ t create function to automatically split data to multiple QR codes. It’s best if library handles one big data to be encoded, and automatically split into appropriate QR codes, and return multiple QR code bitmaps, but this will need big modification in source code. I only made modification to Zxing source code as follow: Add function name to create structured array QR code Add flag, current page, total page, and parity to header data Split data, calculating pages, and parity is done on …

Read/Write multi QR code using Zxing Part2 : Reading QR

Reading structured array isn’t difficult; you can use Zxing library as is. Below is part of source code from my Animal Crossing designer app. Data is decoded to Binary (since QR data is binary in Animal Crossing), and decodeHint parameter is set that way. For structured array QR code, total pages, current page, and other info is written in header part. To get header data, above getRawBytes() function is used. This function returns all raw QR code data including header data. For structured array QR code, leading 5 bytes has following data. 4bit on left side of 0 byte in QR code header is 3 N is current number of …