tag:blogger.com,1999:blog-52320285291081239682023-06-20T05:19:37.035-07:00dr.evil's blogdr.evilhttp://www.blogger.com/profile/17353931646338619791noreply@blogger.comBlogger17125tag:blogger.com,1999:blog-5232028529108123968.post-45870815645215073962011-07-13T05:47:00.000-07:002011-07-13T05:47:15.665-07:00android: howto dump logcat to fileadb logcat *:I -d >log.txt<br />
<br />
<b>*:I</b> all tags' log level above 'Info'<br />
<b>-d > log.txt</b> dump to file log.txt<br />
<br />
<a href="http://developer.android.com/guide/developing/tools/adb.html#logcat">http://developer.android.com/guide/developing/tools/adb.html#logcat</a><br />
<br />
DDMS is not reliable esp. for showing very frequent log display.<br />
If frequent log analysis is required, I use adb logcat dump instead.dr.evilhttp://www.blogger.com/profile/17353931646338619791noreply@blogger.com0tag:blogger.com,1999:blog-5232028529108123968.post-62178934287060305882011-05-24T00:45:00.000-07:002011-05-24T00:45:39.862-07:00android: toggle stagefright'build.prop' has a property for that.<br />
<br />
<br />
#<br />
# system props for the MM modules<br />
#<br />
media.stagefright.enable-player=true<br />
media.stagefright.enable-meta=false<br />
media.stagefright.enable-scan=false<br />
media.stagefright.enable-http=true<br />
<br />
#setprop media.stagefright.enable-player false<br />
can turn off the stagefright and makes media player runs with opencore.dr.evilhttp://www.blogger.com/profile/17353931646338619791noreply@blogger.com0tag:blogger.com,1999:blog-5232028529108123968.post-24416683506004464202011-05-04T19:16:00.000-07:002011-05-05T02:24:14.084-07:00android: link third party static libraries with PREBUILT_STATIC_LIBRARYYou have to declare each library as LOCAL_MODULE.<br />
And each LOCAL_SRC_FILES should have only one .a file.<br />
<div style="font-family: "Courier New",Courier,monospace;"><span style="font-size: x-small;"><br />
<b><span style="font-size: small;">Android.mk:</span></b></span></div><div style="font-family: "Courier New",Courier,monospace;"><b><span style="font-size: small;"><br />
</span></b></div><pre class="lang-java prettyprint"><b><code><span style="font-size: small;"><span class="pln" style="font-family: "Courier New",Courier,monospace;">LOCAL_PATH </span><span class="pun" style="font-family: "Courier New",Courier,monospace;">:=</span><span class="pln" style="font-family: "Courier New",Courier,monospace;"> $</span><span class="pun" style="font-family: "Courier New",Courier,monospace;">(</span><span class="pln" style="font-family: "Courier New",Courier,monospace;">call my</span><span class="pun" style="font-family: "Courier New",Courier,monospace;">-</span><span class="pln" style="font-family: "Courier New",Courier,monospace;">dir</span><span class="pun" style="font-family: "Courier New",Courier,monospace;">)</span><span class="pln" style="font-family: "Courier New",Courier,monospace;">
include $</span><span class="pun" style="font-family: "Courier New",Courier,monospace;">(</span><span class="pln" style="font-family: "Courier New",Courier,monospace;">CLEAR_VARS</span><span class="pun" style="font-family: "Courier New",Courier,monospace;">)</span><span class="pln" style="font-family: "Courier New",Courier,monospace;">
LOCAL_MODULE </span><span class="pun" style="font-family: "Courier New",Courier,monospace;">:=</span><span class="pln" style="font-family: "Courier New",Courier,monospace;"> foo
LOCAL_SRC_FILES </span><span class="pun" style="font-family: "Courier New",Courier,monospace;">:=</span><span class="pln" style="font-family: "Courier New",Courier,monospace;"> libfoo</span><span class="pun" style="font-family: "Courier New",Courier,monospace;">.</span><span class="pln" style="font-family: "Courier New",Courier,monospace;">a
LOCAL_EXPORT_C_INCLUDES </span><span class="pun" style="font-family: "Courier New",Courier,monospace;">:=</span><span class="pln" style="font-family: "Courier New",Courier,monospace;"> $</span><span class="pun" style="font-family: "Courier New",Courier,monospace;">(</span><span class="pln" style="font-family: "Courier New",Courier,monospace;">LOCAL_PATH</span><span class="pun" style="font-family: "Courier New",Courier,monospace;">)/</span><span class="pln" style="font-family: "Courier New",Courier,monospace;">include
include $</span><span class="pun" style="font-family: "Courier New",Courier,monospace;">(</span><span class="pln" style="font-family: "Courier New",Courier,monospace;">PREBUILT_STATIC_LIBRARY</span><span class="pun" style="font-family: "Courier New",Courier,monospace;">)</span></span><span class="pln">
</span></code></b></pre><br />
And link this LOCAL_MODULE using LOCAL_STATIC_LIBRARIES<br />
<br />
<b><span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">Android.mk(continue) </span></span></b><br />
<b><span style="font-size: small;"><br />
</span></b><br />
<b><span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">include $(CLEAR_VARS)</span><br style="font-family: "Courier New",Courier,monospace;" /><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;">LOCAL_MODULE := bar</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;">LOCAL_LDLIBS := -llog -ldl</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;">LOCAL_SRC_FILES := bar.c</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;">LOCAL_STATIC_LIBRARIES := foo</span><br style="font-family: "Courier New",Courier,monospace;" /><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;">include $(BUILD_SHARED_LIBRARY)</span></span></b> <br />
<br />
Now libbar.so will be built with third party library libfoo.a.<br />
<br />
For the details, see ndk docs(ANDROID-MK.html and PREBUILTS.html).<br />
<br />
<br />
p.s. You can NOT link static library to built a new static library in ndk.dr.evilhttp://www.blogger.com/profile/17353931646338619791noreply@blogger.com0tag:blogger.com,1999:blog-5232028529108123968.post-45409836360255238762011-04-15T04:56:00.000-07:002011-04-25T03:18:45.056-07:00PBKDF2 & symmetric crypto(such as AES)<div style="font-family: inherit;"><span style="font-size: small;">PBKDF2(</span>Password-Based Key Derivation Function)<span style="font-size: small;"> </span></div><div style="font-family: inherit;"><br />
</div><span style="font-size: small;">salt + password -> key</span><br />
<br />
<span style="font-size: small;">salt: randomly generated #</span><br />
<span style="font-size: small;">password: passphrase</span><br />
<span style="font-size: small;">PBKDFS hashes password multiple times with salt to derive a key value.</span><br />
<span style="font-size: small;"><br />
</span><br />
<span style="font-size: small;">AES-CBC</span><br />
<span style="font-size: small;"><br />
</span><br />
<span style="font-size: small;"></span>data + (IV + key) -> encrypted data<br />
encrypted data + (IV + key) -> data<br />
<span style="font-size: small;"></span><br />
<div style="font-family: inherit;"><br />
</div><div style="font-family: inherit;"><span style="font-size: small;"><a href="http://en.wikipedia.org/wiki/PBKDF2">http://en.wikipedia.org/wiki/PBKDF2</a> </span></div><div style="font-family: inherit;"><span style="font-size: small;"><a href="http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation">http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation)</a></span></div><div style="font-family: inherit;"><br />
</div><div style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: small;"><br />
</span></div>dr.evilhttp://www.blogger.com/profile/17353931646338619791noreply@blogger.com0tag:blogger.com,1999:blog-5232028529108123968.post-19054998459692175582011-03-28T01:18:00.001-07:002011-03-30T23:59:05.913-07:00android: in app billing overview<a href="http://developer.android.com/guide/market/billing/billing_overview.html">http://developer.android.com/guide/market/billing/billing_overview.html</a><br />
<br />
FMI.dr.evilhttp://www.blogger.com/profile/17353931646338619791noreply@blogger.com0tag:blogger.com,1999:blog-5232028529108123968.post-76153231367320207292011-03-20T23:54:00.000-07:002011-03-31T00:23:55.788-07:00android: activity's onResume vs onWindowFocusChanged<br style="font-family: Georgia,"Times New Roman",serif;" /><br style="font-family: Georgia,"Times New Roman",serif;" /><span style="font-family: Georgia,"Times New Roman",serif;">From activity.java onResume's comment:</span><br style="font-family: Georgia,"Times New Roman",serif;" /><br style="font-family: Georgia,"Times New Roman",serif;" /><br style="font-family: Georgia,"Times New Roman",serif;" /><br style="font-family: Georgia,"Times New Roman",serif;" /><br style="font-family: Georgia,"Times New Roman",serif;" /><span style="font-family: Georgia,"Times New Roman",serif;">Called after onRestoreInstanceState, onRestart, or onPause, for your activity to start interacting with the user. This is a good place to begin animations, open exclusive-access devices (such as the camera), etc. </span><br style="font-family: Georgia,"Times New Roman",serif;" /><br style="font-family: Georgia,"Times New Roman",serif;" /><span style="font-family: Georgia,"Times New Roman",serif;">Keep in mind that onResume is not the best indicator that your activity is visible to the user; a system window such as the keyguard may be in front. Use onWindowFocusChanged to know for certain that your activity is visible to the user (for example, to resume a game). </span><br style="font-family: Georgia,"Times New Roman",serif;" /><br style="font-family: Georgia,"Times New Roman",serif;" /><span style="font-family: Georgia,"Times New Roman",serif;">Derived classes must call through to the super class's implementation of this method. If they do not, an exception will be thrown.</span>dr.evilhttp://www.blogger.com/profile/17353931646338619791noreply@blogger.com0tag:blogger.com,1999:blog-5232028529108123968.post-12997527216591013462011-01-11T04:01:00.000-08:002011-03-31T00:00:51.720-07:00android: How to see the routing table and dns in adb shell<div style="font-family: "Courier New",Courier,monospace;"><span style="font-size: small;"><a href="http://groups.google.com/group/android-platform/browse_thread/thread/e0a75cce49273357">http://groups.google.com/group/android-platform/browse_thread/thread/e0a75cce49273357</a></span></div><div style="font-family: "Courier New",Courier,monospace;"><span style="font-size: small;"><br />
</span></div><div style="font-family: "Courier New",Courier,monospace;"><span style="font-size: small;">For checking DNS server addresses, you can use getprop, such <br />
as: </span> </div><div style="font-family: "Courier New",Courier,monospace;"><span style="font-size: small;">| # getprop net.dns1 <br />
| 192.168.32.18 </span> </div><div style="font-family: "Courier New",Courier,monospace;"><span style="font-size: small;">or, if you'd like to know the values which dhcp server <br />
offers: </span> </div><div style="font-family: "Courier New",Courier,monospace;"><span style="font-size: small;">| # getprop dhcp.tiwlan0.dns1 <br />
| 192.168.32.18 </span> </div><div style="font-family: "Courier New",Courier,monospace;"><span style="font-size: small;">You also can see dhcp supply default gateway value: </span> </div><div style="font-family: "Courier New",Courier,monospace;"><span style="font-size: small;">| # getprop dhcp.tiwlan0.gateway <br />
| 192.168.32.1 </span> </div><div style="font-family: "Courier New",Courier,monospace;"><span style="font-size: small;">You might see all property values if you exec 'getprop' <br />
without arguments. </span> </div><div style="font-family: "Courier New",Courier,monospace;"><span style="font-size: small;">If you'd like to see live routing table, the easiest(but <br />
complicated to understand) way is to see /proc/net/route. </span> </div><div style="font-family: "Courier New",Courier,monospace;"><span style="font-size: small;">| # cat /proc/net/route <br />
| Iface Destination Gateway Flags RefCnt Use Metric Mask MTU Window IRTT <br />
| tiwlan0 0020A8C0 00000000 0001 0 0 0 00FFFFFF 0 0 0 <br />
| tiwlan0 00000000 0120A8C0 0003 0 0 0 00000000 0 0 0 </span> </div><span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">The Destination '00000000' means, of course, default route </span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;"> and Gateway value '0120A8C0' means '1.32.168.192' in </span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;"> decimal('192.168.32.1' in reverse), so you can know what is </span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;"> default gateway address is. </span></span><br />
<div style="font-family: "Courier New",Courier,monospace;"><span style="font-size: small;"><br />
</span></div><div style="font-family: "Courier New",Courier,monospace;"><span style="font-size: small;"><br />
</span></div><div style="font-family: "Courier New",Courier,monospace;"><span style="font-size: small;"><br />
</span></div>dr.evilhttp://www.blogger.com/profile/17353931646338619791noreply@blogger.com0tag:blogger.com,1999:blog-5232028529108123968.post-37866022675113516142011-01-05T00:12:00.000-08:002011-03-31T00:10:50.571-07:00linux: (link) changing network adapter priority<div style="font-family: "Courier New",Courier,monospace;"><a href="http://superuser.com/questions/216678/ubuntu-network-priority">http://superuser.com/questions/216678/ubuntu-network-priority</a></div><div style="font-family: "Courier New",Courier,monospace;"><br />
</div><div style="font-family: "Courier New",Courier,monospace;">In short: Network card priority is decided by calculated routing speed so you cannot manually change it easily. However, you can set an adapter never to be a default network connection by setting 'Use this connection only for resources on its network' at 'System->Preferences->Network Connections->Edit->IPv4 Setting->Routes...'.</div>dr.evilhttp://www.blogger.com/profile/17353931646338619791noreply@blogger.com0tag:blogger.com,1999:blog-5232028529108123968.post-44452300139297466752011-01-04T01:02:00.000-08:002011-03-31T00:11:16.501-07:00linux: how to setup your linux as internet gateway(Ubuntu 9.10)<div style="font-family: "Courier New",Courier,monospace;">There are many posts about this topic however some of them are quite old.</div><div style="font-family: "Courier New",Courier,monospace;">Here's the simple instruction of doing it.</div><div style="font-family: "Courier New",Courier,monospace;"><b><br />
</b></div><div style="font-family: "Courier New",Courier,monospace;"><b>0. Prerequisites</b></div><div style="font-family: "Courier New",Courier,monospace;"><br />
</div><div style="font-family: "Courier New",Courier,monospace;">Linux machine with 2 network adapters.</div><div style="font-family: "Courier New",Courier,monospace;">A Laptop usually have two network adapters: one for LAN, one for Wi-fi.</div><div style="font-family: "Courier New",Courier,monospace;"><br />
</div><div style="font-family: "Courier New",Courier,monospace;">Below, I have two adapters connected to:</div><div style="font-family: "Courier New",Courier,monospace;"><br />
</div><div style="font-family: "Courier New",Courier,monospace;"> eth1: connected to private network</div><div style="font-family: "Courier New",Courier,monospace;"> wlan1: connected to internet</div><div style="font-family: "Courier New",Courier,monospace;"></div><div style="font-family: "Courier New",Courier,monospace;"><b><br />
</b></div><div style="font-family: "Courier New",Courier,monospace;"><b>1. turn on ip forward functionality</b></div><div style="font-family: "Courier New",Courier,monospace;"><br />
</div><div style="font-family: "Courier New",Courier,monospace;">open /etc/sysctl.conf</div><div style="font-family: "Courier New",Courier,monospace;">uncomment(or change if set to 0) net.ipv4.ip_forward = 1</div><div style="font-family: "Courier New",Courier,monospace;">$sysctl -p /etc/sysctl.conf</div><div style="font-family: "Courier New",Courier,monospace;"><br />
</div><div style="font-family: "Courier New",Courier,monospace;">you can check whether it is correctly set or not with</div><div style="font-family: "Courier New",Courier,monospace;">$cat /proc/sys/net/ipv4/ip_forward</div><div style="font-family: "Courier New",Courier,monospace;">1</div><div style="font-family: "Courier New",Courier,monospace;"><br />
</div><div style="font-family: "Courier New",Courier,monospace;"><b><br />
</b></div><div style="font-family: "Courier New",Courier,monospace;"><b>2. setup ip forwarding & masquerading</b></div><div style="font-family: "Courier New",Courier,monospace;"><br />
</div><div style="font-family: "Courier New",Courier,monospace;">Reminder: wlan1 is to internet, eth1 is to intranet(local network) </div><div style="font-family: "Courier New",Courier,monospace;"><br />
</div><div style="font-family: "Courier New",Courier,monospace;">$iptables -t nat -A POSTROUTING -o wlan1 -j MASQUERADE</div><div style="font-family: "Courier New",Courier,monospace;">$iptables -A FORWARD -i eth1 -j ACCEPT</div><div style="font-family: "Courier New",Courier,monospace;"><br />
</div><div style="font-family: "Courier New",Courier,monospace;">Simply done. </div><div style="font-family: "Courier New",Courier,monospace;"><br />
</div><div style="font-family: "Courier New",Courier,monospace;">Now change gateway of your local network pc to linux machine's IP address and you can use internet from your local network pc via linux gateway.</div><div style="font-family: "Courier New",Courier,monospace;"><br />
</div><div style="font-family: "Courier New",Courier,monospace;"><b>3. troubleshooting</b></div><div style="font-family: "Courier New",Courier,monospace;"><br />
</div><div style="font-family: "Courier New",Courier,monospace;">If you cannot access internet from your local network pc, check linux machine's routing table.</div><div style="font-family: "Courier New",Courier,monospace;"><br />
</div><div style="font-family: "Courier New",Courier,monospace;">$ip ro</div><div style="font-family: "Courier New",Courier,monospace;">192.168.16.0/24 dev wlan1 proto kernel scope link src 192.168.16.21 metric 2</div><div style="font-family: "Courier New",Courier,monospace;">192.168.0.0/24 dev eth1 proto kernel scope link src 192.168.0.58 metric 1</div><div style="font-family: "Courier New",Courier,monospace;">...</div><div style="font-family: "Courier New",Courier,monospace;">default via 192.168.0.1 dev eth1</div><div style="font-family: "Courier New",Courier,monospace;"><br />
</div><div style="font-family: "Courier New",Courier,monospace;">As above, if eth1(private network) is set as default route, change default route to wlan1(internet) by:</div><div style="font-family: "Courier New",Courier,monospace;">$ip ro change default via xxx.xxx.xxx.xxx dev wlan1</div><div style="font-family: "Courier New",Courier,monospace;">$ip ro flush cache <br />
<br />
</div><div style="font-family: "Courier New",Courier,monospace;">where xxx.xxx.xxx.xxx is your wlan1(internet accessible adpater) gateway.</div>dr.evilhttp://www.blogger.com/profile/17353931646338619791noreply@blogger.com0tag:blogger.com,1999:blog-5232028529108123968.post-56753359178836865322010-12-17T00:46:00.000-08:002011-03-31T00:11:58.666-07:00android: howto put custom .so to /system/lib dir<div style="font-family: "Courier New",Courier,monospace;">There are two problems:</div><div style="font-family: "Courier New",Courier,monospace;"><br />
</div><div style="font-family: "Courier New",Courier,monospace;">1. no permission to write to /system/lib --> chmod /system/lib</div><div style="font-family: "Courier New",Courier,monospace;">2. you cannot chmod /system dir because it is ro file system --> remount it as rw file system</div><div style="font-family: "Courier New",Courier,monospace;"><br />
</div><div style="font-family: "Courier New",Courier,monospace;">Here are the steps:</div><div style="font-family: "Courier New",Courier,monospace;"><br />
</div><div style="font-family: "Courier New",Courier,monospace;"><br />
</div><div style="font-family: "Courier New",Courier,monospace;">1. remount /system with rw</div><div style="font-family: "Courier New",Courier,monospace;"></div><div style="font-family: "Courier New",Courier,monospace;"><br />
</div><div style="font-family: "Courier New",Courier,monospace;"># mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system</div><div style="font-family: "Courier New",Courier,monospace;"><br />
</div><div style="font-family: "Courier New",Courier,monospace;">your devices mounting point can be identified with simple 'mount' cmd at shell.</div><div style="font-family: "Courier New",Courier,monospace;"><br />
</div><div style="font-family: "Courier New",Courier,monospace;">2. chmod /system/lib</div><div style="font-family: "Courier New",Courier,monospace;"><br />
</div><div style="font-family: "Courier New",Courier,monospace;"># chmod 6755 /system/lib</div><div style="font-family: "Courier New",Courier,monospace;"><br />
</div><div style="font-family: "Courier New",Courier,monospace;">3. push your .so to /system/lib</div><div style="font-family: "Courier New",Courier,monospace;"><br />
</div><div style="font-family: "Courier New",Courier,monospace;">adb push your_custom.so /system/lib</div>dr.evilhttp://www.blogger.com/profile/17353931646338619791noreply@blogger.com2tag:blogger.com,1999:blog-5232028529108123968.post-2114559682527976912010-12-16T02:07:00.000-08:002011-03-31T00:12:25.923-07:00android: MediaPlayer or VideoView reports -38, 0 error<div style="font-family: "Courier New",Courier,monospace;">In my case, it was due to pause the mediaPlayer when it was not playing.</div><div style="font-family: "Courier New",Courier,monospace;"><br />
</div><div style="font-family: "Courier New",Courier,monospace;">Make sure that object is in expected state. It is always a good habit in programming.</div><div style="font-family: "Courier New",Courier,monospace;"><br />
</div><div style="font-family: "Courier New",Courier,monospace;"> if (_mediaPlayer.isPlaying() == true) {</div><div style="font-family: "Courier New",Courier,monospace;"> _mediaPlayer.pause(); </div><span style="font-family: "Courier New",Courier,monospace;"> }</span>dr.evilhttp://www.blogger.com/profile/17353931646338619791noreply@blogger.com0tag:blogger.com,1999:blog-5232028529108123968.post-50696792775603912732010-12-02T22:12:00.000-08:002011-03-31T00:12:45.576-07:00android: pause any other media players<div style="font-family: "Courier New",Courier,monospace;">The answer is in the VideoView.java src.</div><div style="font-family: "Courier New",Courier,monospace;"><br />
</div><pre style="font-family: "Courier New",Courier,monospace;"><span style="color: #2040a0;">Intent</span> <span style="color: #2040a0;">i</span> <span style="color: #4444ff;">=</span> <b>new</b> <span style="color: #2040a0;">Intent</span><span style="color: #4444ff;"><b>(</b></span><span style="color: green;">"com.android.music.musicservicecommand"</span><span style="color: #4444ff;"><b>)</b></span><span style="color: #4444ff;">;</span>
<span style="color: #2040a0;">i</span>.<span style="color: #2040a0;">putExtra</span><span style="color: #4444ff;"><b>(</b></span><span style="color: green;">"command"</span>, <span style="color: green;">"pause"</span><span style="color: #4444ff;"><b>)</b></span><span style="color: #4444ff;">;</span>
<span style="color: #2040a0;">context</span>.<span style="color: #2040a0;">sendBroadcast</span><span style="color: #4444ff;"><b>(</b></span><span style="color: #2040a0;">i</span><span style="color: #4444ff;"><b>)</b></span><span style="color: #4444ff;">;</span></pre><pre style="font-family: "Courier New",Courier,monospace;"></pre><pre style="font-family: "Courier New",Courier,monospace;"> </pre><pre style="font-family: "Courier New",Courier,monospace;">On the other hand, if you are developing music/video player of your own, </pre><pre style="font-family: "Courier New",Courier,monospace;">you may want to register a broadcast receiver for it as well.</pre>dr.evilhttp://www.blogger.com/profile/17353931646338619791noreply@blogger.com0tag:blogger.com,1999:blog-5232028529108123968.post-41924326695461934622010-11-17T00:00:00.000-08:002011-03-31T00:13:02.067-07:00android: Forcing View's onMeasure be called(by its parent)Call child view's 'requestLayout()' function,<br />
<br />
ex)<br />
<br />
public void toggleFillScreen() {<br />
fillScreen = !fillScreen;<br />
requestLayout();<br />
}<br />
<br />
@Override<br />
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {<br />
if (fillScreen == true) {<br />
int width = defaultDisplay.getWidth();<br />
int height = defaultDisplay.getHeight();<br />
Log.i(TAG, "defaultDisplay width=" + defaultDisplay.getWidth() + " height=" + defaultDisplay.getHeight());<br />
Log.i(TAG, "onMeasure width=" + width + " height=" + height);<br />
setMeasuredDimension(width, height); <br />
} else {<br />
super.onMeasure(widthMeasureSpec, heightMeasureSpec);<br />
}<br />
}<br />
<br />
Checking VideoView.java source at <a href="http://www.netmite.com/android/mydroid/frameworks/base/core/java/android/widget/VideoView.java">http://www.netmite.com/android/mydroid/frameworks/base/core/java/android/widget/VideoView.java</a> will be helpful.dr.evilhttp://www.blogger.com/profile/17353931646338619791noreply@blogger.com0tag:blogger.com,1999:blog-5232028529108123968.post-36021090283351638572010-10-20T20:01:00.000-07:002011-03-31T00:13:15.755-07:00eclipse: workspace in use messageif it is obvious that no other eclipse instance is running but you have trouble with this message, delete '.metadata/.lock' file at workspace folder.dr.evilhttp://www.blogger.com/profile/17353931646338619791noreply@blogger.com0tag:blogger.com,1999:blog-5232028529108123968.post-7196527144793247452010-10-13T19:34:00.000-07:002011-03-31T00:13:34.357-07:00android: get device's android sdk version<div style="font-family: "Courier New",Courier,monospace;">android.os.Build.VERSION</div><div style="font-family: "Courier New",Courier,monospace;"><br />
</div><div style="font-family: "Courier New",Courier,monospace;">ex)</div><div style="font-family: "Courier New",Courier,monospace;"> if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.FROYO) {</div><div style="font-family: "Courier New",Courier,monospace;"> transformXmlUrlWithXsl(url);</div><div style="font-family: "Courier New",Courier,monospace;"> }</div>dr.evilhttp://www.blogger.com/profile/17353931646338619791noreply@blogger.com0tag:blogger.com,1999:blog-5232028529108123968.post-37499098084091116252010-10-07T23:16:00.000-07:002011-03-31T00:14:01.139-07:00xsl: linking external css with xsl<div style="font-family: "Courier New",Courier,monospace;">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.</div><div style="font-family: "Courier New",Courier,monospace;"><br />
</div><div style="font-family: "Courier New",Courier,monospace;"><?xml version="1.0" encoding="ISO-8859-1"?><br />
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><br />
<xsl:template match="/"><br />
<html xmlns="http://www.w3.org/1999/xhtml"><br />
<script type="text/javascript" src="sample.js"></script><br />
<head><br />
<b style="color: black;"><link rel="stylesheet" type="text/css" href="sample.css"/></b><br />
</head><br />
<body></div><span style="font-family: "Courier New",Courier,monospace;">...</span>dr.evilhttp://www.blogger.com/profile/17353931646338619791noreply@blogger.com0tag:blogger.com,1999:blog-5232028529108123968.post-16872195967403845562010-10-06T23:40:00.000-07:002011-03-31T00:14:17.587-07:00xsl: document.write() is not working<div style="font-family: "Courier New",Courier,monospace;"><span style="font-size: small;">When document.write is not working at xsl with your browser, setting value to DOM node's innerHTML could be an option. </span></div><div style="font-family: "Courier New",Courier,monospace;"><span style="font-size: small;"><br />
</span></div><div style="font-family: "Courier New",Courier,monospace;"><span style="font-size: small;">Here's the simple example of xsl file. </span></div><div style="font-family: "Courier New",Courier,monospace;"><span style="font-size: small;"><br />
</span></div><div style="font-family: "Courier New",Courier,monospace;"><span style="font-size: small;"><?xml version="1.0" encoding="ISO-8859-1"?></span></div><div style="font-family: "Courier New",Courier,monospace;"><span style="font-size: small;"><html xsl:version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml"></span></div><div style="font-family: "Courier New",Courier,monospace;"><span style="font-size: small;"><body></span></div><div style="font-family: "Courier New",Courier,monospace;"><span style="font-size: small;"> <script type="text/javascript"></span></div><div style="font-family: "Courier New",Courier,monospace;"><span style="font-size: small;"> <![CDATA[</span></div><div style="font-family: "Courier New",Courier,monospace;"><span style="font-size: small;"> document.write("Hello World by document.write");</span></div><div style="font-family: "Courier New",Courier,monospace;"><span style="font-size: small;"> ]]></span></div><div style="font-family: "Courier New",Courier,monospace;"><span style="font-size: small;"> </script></span></div><div style="font-family: "Courier New",Courier,monospace;"><span style="font-size: small;"> </span></div><div style="font-family: "Courier New",Courier,monospace;"><span style="font-size: small;"> <div class="foo" id="foo1"></div></span></div><div style="font-family: "Courier New",Courier,monospace;"><span style="font-size: small;"> <div class="foo" id="foo2"></div></span></div><div style="font-family: "Courier New",Courier,monospace;"><span style="font-size: small;"> <div class="foo" id="foo3"></div></span></div><div style="font-family: "Courier New",Courier,monospace;"><span style="font-size: small;"> <script type="text/javascript"></span></div><div style="font-family: "Courier New",Courier,monospace;"><span style="font-size: small;"> <![CDATA[</span></div><div style="font-family: "Courier New",Courier,monospace;"><span style="font-size: small;"> foos = document.getElementsByClassName("foo");</span></div><div style="font-family: "Courier New",Courier,monospace;"><span style="font-size: small;"> for(i=0; i<foos.length; i++) {</span></div><div style="font-family: "Courier New",Courier,monospace;"><span style="font-size: small;"> foos[i].innerHTML = "Hello World by innerHTML";</span></div><div style="font-family: "Courier New",Courier,monospace;"><span style="font-size: small;"> }</span></div><div style="font-family: "Courier New",Courier,monospace;"><span style="font-size: small;"> ]]></span></div><div style="font-family: "Courier New",Courier,monospace;"><span style="font-size: small;"> </script></span></div><div style="font-family: "Courier New",Courier,monospace;"><span style="font-size: small;"></body></span></div><div style="font-family: "Courier New",Courier,monospace;"><span style="font-size: small;"></html></span></div><div style="font-family: "Courier New",Courier,monospace;"><span style="font-size: small;"><br />
</span></div><div style="font-family: "Courier New",Courier,monospace;"><span style="font-size: small;"><br />
</span></div><div style="font-family: "Courier New",Courier,monospace;"><span style="font-size: small;"><br />
</span></div><div style="font-family: "Courier New",Courier,monospace;"><span style="font-size: small;">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.</span></div>dr.evilhttp://www.blogger.com/profile/17353931646338619791noreply@blogger.com0