adb logcat *:I -d >log.txt
*:I all tags' log level above 'Info'
-d > log.txt dump to file log.txt
http://developer.android.com/guide/developing/tools/adb.html#logcat
DDMS is not reliable esp. for showing very frequent log display.
If frequent log analysis is required, I use adb logcat dump instead.
2011-07-13
2011-05-24
android: toggle stagefright
'build.prop' has a property for that.
#
# system props for the MM modules
#
media.stagefright.enable-player=true
media.stagefright.enable-meta=false
media.stagefright.enable-scan=false
media.stagefright.enable-http=true
#setprop media.stagefright.enable-player false
can turn off the stagefright and makes media player runs with opencore.
#
# system props for the MM modules
#
media.stagefright.enable-player=true
media.stagefright.enable-meta=false
media.stagefright.enable-scan=false
media.stagefright.enable-http=true
#setprop media.stagefright.enable-player false
can turn off the stagefright and makes media player runs with opencore.
2011-05-04
android: link third party static libraries with PREBUILT_STATIC_LIBRARY
You have to declare each library as LOCAL_MODULE.
And each LOCAL_SRC_FILES should have only one .a file.
Android.mk:
And link this LOCAL_MODULE using LOCAL_STATIC_LIBRARIES
Android.mk(continue)
include $(CLEAR_VARS)
LOCAL_MODULE := bar
LOCAL_LDLIBS := -llog -ldl
LOCAL_SRC_FILES := bar.c
LOCAL_STATIC_LIBRARIES := foo
include $(BUILD_SHARED_LIBRARY)
Now libbar.so will be built with third party library libfoo.a.
For the details, see ndk docs(ANDROID-MK.html and PREBUILTS.html).
p.s. You can NOT link static library to built a new static library in ndk.
And each LOCAL_SRC_FILES should have only one .a file.
Android.mk:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := foo
LOCAL_SRC_FILES := libfoo.a
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_STATIC_LIBRARY)
And link this LOCAL_MODULE using LOCAL_STATIC_LIBRARIES
Android.mk(continue)
include $(CLEAR_VARS)
LOCAL_MODULE := bar
LOCAL_LDLIBS := -llog -ldl
LOCAL_SRC_FILES := bar.c
LOCAL_STATIC_LIBRARIES := foo
include $(BUILD_SHARED_LIBRARY)
Now libbar.so will be built with third party library libfoo.a.
For the details, see ndk docs(ANDROID-MK.html and PREBUILTS.html).
p.s. You can NOT link static library to built a new static library in ndk.
2011-04-15
PBKDF2 & symmetric crypto(such as AES)
PBKDF2(Password-Based Key Derivation Function)
salt: randomly generated #
password: passphrase
PBKDFS hashes password multiple times with salt to derive a key value.
AES-CBC
data + (IV + key) -> encrypted data
encrypted data + (IV + key) -> data
2011-03-28
2011-03-20
android: activity's onResume vs onWindowFocusChanged
From activity.java onResume's comment:
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.
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).
Derived classes must call through to the super class's implementation of this method. If they do not, an exception will be thrown.
2011-01-11
android: How to see the routing table and dns in adb shell
For checking DNS server addresses, you can use getprop, such
as:
as:
| # getprop net.dns1
| 192.168.32.18
| 192.168.32.18
or, if you'd like to know the values which dhcp server
offers:
offers:
| # getprop dhcp.tiwlan0.dns1
| 192.168.32.18
| 192.168.32.18
You also can see dhcp supply default gateway value:
| # getprop dhcp.tiwlan0.gateway
| 192.168.32.1
| 192.168.32.1
You might see all property values if you exec 'getprop'
without arguments.
without arguments.
If you'd like to see live routing table, the easiest(but
complicated to understand) way is to see /proc/net/route.
complicated to understand) way is to see /proc/net/route.
| # cat /proc/net/route
| Iface Destination Gateway Flags RefCnt Use Metric Mask MTU Window IRTT
| tiwlan0 0020A8C0 00000000 0001 0 0 0 00FFFFFF 0 0 0
| tiwlan0 00000000 0120A8C0 0003 0 0 0 00000000 0 0 0
The Destination '00000000' means, of course, default route | Iface Destination Gateway Flags RefCnt Use Metric Mask MTU Window IRTT
| tiwlan0 0020A8C0 00000000 0001 0 0 0 00FFFFFF 0 0 0
| tiwlan0 00000000 0120A8C0 0003 0 0 0 00000000 0 0 0
and Gateway value '0120A8C0' means '1.32.168.192' in
decimal('192.168.32.1' in reverse), so you can know what is
default gateway address is.
2011-01-05
linux: (link) changing network adapter priority
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...'.
2011-01-04
linux: how to setup your linux as internet gateway(Ubuntu 9.10)
There are many posts about this topic however some of them are quite old.
Here's the simple instruction of doing it.
0. Prerequisites
Linux machine with 2 network adapters.
A Laptop usually have two network adapters: one for LAN, one for Wi-fi.
Below, I have two adapters connected to:
eth1: connected to private network
wlan1: connected to internet
1. turn on ip forward functionality
open /etc/sysctl.conf
uncomment(or change if set to 0) net.ipv4.ip_forward = 1
$sysctl -p /etc/sysctl.conf
you can check whether it is correctly set or not with
$cat /proc/sys/net/ipv4/ip_forward
1
2. setup ip forwarding & masquerading
Reminder: wlan1 is to internet, eth1 is to intranet(local network)
$iptables -t nat -A POSTROUTING -o wlan1 -j MASQUERADE
$iptables -A FORWARD -i eth1 -j ACCEPT
Simply done.
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.
3. troubleshooting
If you cannot access internet from your local network pc, check linux machine's routing table.
$ip ro
192.168.16.0/24 dev wlan1 proto kernel scope link src 192.168.16.21 metric 2
192.168.0.0/24 dev eth1 proto kernel scope link src 192.168.0.58 metric 1
...
default via 192.168.0.1 dev eth1
As above, if eth1(private network) is set as default route, change default route to wlan1(internet) by:
$ip ro change default via xxx.xxx.xxx.xxx dev wlan1
$ip ro flush cache
where xxx.xxx.xxx.xxx is your wlan1(internet accessible adpater) gateway.
2010-12-17
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
2010-12-16
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) {
_mediaPlayer.pause();
}
Labels:
android,
mediaplayer
2010-12-02
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"); context.sendBroadcast(i);
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.
Labels:
android,
mediaplayer
2010-11-17
android: Forcing View's onMeasure be called(by its parent)
Call child view's 'requestLayout()' function,
ex)
public void toggleFillScreen() {
fillScreen = !fillScreen;
requestLayout();
}
@Override
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.
ex)
public void toggleFillScreen() {
fillScreen = !fillScreen;
requestLayout();
}
@Override
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.
2010-10-20
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.
2010-10-13
android: get device's android sdk version
android.os.Build.VERSION
ex)
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.FROYO) {
transformXmlUrlWithXsl(url);
}
2010-10-07
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>
<head>
<link rel="stylesheet" type="text/css" href="sample.css"/>
</head>
<body>
...
<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>
<head>
<link rel="stylesheet" type="text/css" href="sample.css"/>
</head>
<body>
2010-10-06
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">
<body>
<script type="text/javascript">
<![CDATA[
document.write("Hello World by document.write");
]]>
</script>
<div class="foo" id="foo1"></div>
<div class="foo" id="foo2"></div>
<div class="foo" id="foo3"></div>
<script type="text/javascript">
<![CDATA[
foos = document.getElementsByClassName("foo");
for(i=0; i<foos.length; i++) {
foos[i].innerHTML = "Hello World by innerHTML";
}
]]>
</script>
</body>
</html>
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.
피드 구독하기:
글 (Atom)