android: howto put custom .so to /system/lib dir

There are two problems:

1. no permission to write to /system/lib --> chmod /system/lib
2. you cannot chmod /system dir because it is ro file system --> remount it as rw file system

Here are the steps:

1. remount /system with rw

# mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system

your devices mounting point can be identified with simple 'mount' cmd at shell.

2. chmod /system/lib

# chmod 6755 /system/lib

3. push your .so to /system/lib

adb push your_custom.so /system/lib


android: MediaPlayer or VideoView reports -38, 0 error

In my case, it was due to pause the mediaPlayer when it was not playing.

Make sure that object is in expected state. It is always a good habit in programming.

    if (_mediaPlayer.isPlaying() == true) {


android: pause any other media players

The answer is in the VideoView.java src.

Intent i = new Intent("com.android.music.musicservicecommand");
i.putExtra("command", "pause");
On the other hand, if you are developing music/video player of your own, 
you may want to register a broadcast receiver for it as well.


android: Forcing View's onMeasure be called(by its parent)

Call child view's 'requestLayout()' function,


    public void toggleFillScreen() {
        fillScreen = !fillScreen;
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        if (fillScreen == true) {
            int width = defaultDisplay.getWidth();
            int height = defaultDisplay.getHeight();
            Log.i(TAG, "defaultDisplay width=" + defaultDisplay.getWidth() + " height=" + defaultDisplay.getHeight());
            Log.i(TAG, "onMeasure width=" + width + " height=" + height);
            setMeasuredDimension(width, height);
        } else {
            super.onMeasure(widthMeasureSpec, heightMeasureSpec);

Checking VideoView.java source at http://www.netmite.com/android/mydroid/frameworks/base/core/java/android/widget/VideoView.java will be helpful.


eclipse: workspace in use message

if it is obvious that no other eclipse instance is running but you have trouble with this message, delete '.metadata/.lock' file at workspace folder.


android: get device's android sdk version


    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.FROYO) {


xsl: linking external css with xsl

Using XSL for dynamic XML manipulation and CSS for static browser output decoration sounds like a reasonable way for me and for the most people who stand closer to CSS than XSL yet.

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml">
<script type="text/javascript" src="sample.js"></script>
    <link rel="stylesheet" type="text/css" href="sample.css"/>


xsl: document.write() is not working

When document.write is not working at xsl with your browser, setting value to DOM node's innerHTML could be an option.

Here's the simple example of xsl file.

<?xml version="1.0" encoding="ISO-8859-1"?>
<html xsl:version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml">
    <script type="text/javascript">
        document.write("Hello World by document.write");
    <div class="foo" id="foo1"></div>
    <div class="foo" id="foo2"></div>
    <div class="foo" id="foo3"></div>
    <script type="text/javascript">
        foos = document.getElementsByClassName("foo");
        for(i=0; i<foos.length; i++) {
            foos[i].innerHTML = "Hello World by innerHTML";

If you load this xsl with some dummy xml, IE will print out 'Hello World by document.write' only(by lack of 'getElementsByClassName' support) and FF will print out 'Hello World by innerHTML' 3 times.