Showing posts from 2012

Disabling home-button-slide to search by Google now.

As I trying to make an android app for my autism kid, I wanted to disable any button to escape the app without inserting password. I killed homebutton as making it to be a HOME application, I found that my kid sometimes accidentally wonders into other apps through google search by sliding home button. I finally disables (or rather overwrites) it by capturing its intent. The trick is very easy. Just add one line to AndroidManifest. <intent-filter> <action always="always" android:name="android.intent.action.ASSIST /> .... First time adding this, sliding home button makes you to choose what to do, so choose your own app and makes it "always".

Nexus7 doesn't do dual-pane thing on PreferenceActivity

I have been wondering why my PreferenceActivity doesn't become dual-pane(two-panes) mode, and I found it works fine on a tablet other than Nexus7. I confirmed getConfiguration().screenLayout is LARGE, so I wonder this is bug. Anyway my app is meant to work on tablet, so I finally do this class PrefActivity extends PreferenceActivity() { override def onIsMultiPane():Boolean = true } However, this turns the preference activity into dual-pane on any device. If anyone knows better solution, let me know...

ClassNotFoundException on sbt-android-plugin

I tried to create a brand-new scala project for android, but I found it cannot be started by ClassNotFoundException which means MainActivity was not found. Again, it is caused by Proguard and it seems skeleton program created by g8 jberkel/android-app uses proguard by default. To cut proguard, you just comment out "proguardSetting ++" line in project/Build.scala file. Setting "false" to proguardSettings seems not working, so just comment it out.

sbt+ProGuard+addJavascriptInterface = HELL!!

Honestly I really don't understand what's going on, but I have been messed with addJavascriptInterface of WebView(android) used on the sbt project which is using ProGuard for obfuscation for weeks (literally!) I have guessed the problem was caused by obfuscating class names so that WebView cannot find the method, however proguard options were too tricky. After try & errors, I finally made it to work adding following setting to Build.scala proguardOption in Android := List( "-keep public class * extends", "-keep public class com.test.javaInterface", "-keepclassmembers class com.test.javaInterface { <methods> }" ).mkString(" ") The points are -dontobfuscate seems not working. (for my environment at least.) sbt clean seems to be needed every time I changed proguardOption All options should be combined as one line. not only class but classmembers should avoid obfusca

Installing RoboCut on Mountain Lion(max osx 10.7)

Installing RoboCut( Robocut ) on Mac OSX 10.7 Moutain Lion takes a bit of work. 1. Installing qt and libusb brew install qt4 libusb 2. Download Code git clone git:// cd robocut  3. qmake and modify Makefile qmake sed -i.bak -e "%s/10.5/10.7/g" Makefile make  4.enjoy

Empty list in Python

To empty list, list = range(10) del list[:] honestly I do not fully understand how it works, but it works.

Stuck installing Python using Homebrew (Mac OSX Lion)

I tried to install python (once again), but been stuck for a while. So I leave a note for future myself. First of all, brew install python fails due to "permission denied". This has to do with something replacing files under /System/Library/Frameworks/Python.Framework so I changed owner of the folder, though it is a bit uncomfortable. sudo chown $USER /System/Library/Frameworks/Python.Framework After that, I tried installed pip and virtualenv. easy_install pip pip install virtualenv but, pip didn't work complaining "there is no such module named setuptools". I had been stuck this for a while, but solution is written in a message of "brew install python" (I couldn't see it for the first time) Before you use pip, you have to do pip install --upgrade distribute make sure, easy_install and pip is homebrewed. They are under /usr/local/share/python and you should set $PATH like export PATH=/usr/local/share/python:$PATH

Android's VideoView doesn't always stretch video.

Creating a full screen simple video player on Android 2.4.x(GingerBread), I've been annoyed by the problem that VideoView doesn't always stretch videos to full screen(keeping aspect ratio). Reading VideoView's code, I finally found a solution to this. Point is to call getHolder().setFixedSize in onMeasure. class StretchVideoView(context:Context, attr:AttributeSet) extends VideoView(context, attrib) { def measure(measureSpec:Int):Int = { val specMode = View.MeasureSpec.getMode(measureSpec) View.MeasureSpec.getSize(measureSpec) } override def onMeasure(widthMeasureSpec:Int, heightMeasureSpec:Int) { val (w,h) = (measure(widthMeasureSpec), measure(heightMeasureSpec)) getHolder().setFixedSize(w,h) super.onMeasure(widthMeasureSpec, heightMeasureSpec) } } By the way, the above code is written in Scala, so please write in Java if you're not Scala guy (Usually not).


To create a lockdown application on Android, I tried to use FLAG_FULLSCREEN and TYPE_KEYGUARD simultaneously, however using only one of them worked fine but no luck using them together. To avoid this problem, full screen feature seems to be done by AndroidManifest.xml. To do so, add android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" to activity node in AndroidManifest.xml and add following code to Activity class override def onAttachedToWindow() { getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD) super.onAttachedToWidnow }