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. 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: Twitter4j library is used; download from site below and copy required jar file to your libs folder in project. Tweeter4j Next, you need to get a access key. 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.

How to wait for process termination when parent process terminates before child process

If you want to call external process and want to wait for it to terminate, you can call CreateProcess function and wait using WaitForSingeObject API. However, some process just launches child process and terminates immediately, resulting application still running but process terminates and returns to code. Below is sample code you can use in such case, where it monitors for process and child processes, and wait for all family process to terminate.

[C++]Run command within program without showing window / Takeown example

When developing simple tool or doing automation, calling shell command might be easy and fast. However, calling “cmd /c” with ShellExecute brings up shell window, and might return to code before command completes. In such case, use CreateProcess to call cmd. You can hide shell window and wait for process to complete, and even get return value by using CreateProcess API. Below is simple sample code for calling takeown command, which is a command to take ownership of system files which can’t be modified even with Administrator privilege.

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 …