Eros Live
Find the Way
posts - 15,comments - 0,trackbacks - 0

在manifest的activity节点使用

<activity android:windowSoftInputMode="adjustResize" . . . >

当点击EditText控件弹出软键盘的时候,系统会自动调整控件的位置。

代码

http://github.com/shaobin0604/miscandroidapps/tree/master/WindowSoftInputMode/

参考

posted @ 2010-08-25 18:42 Eros 阅读(264) | 评论 (0)编辑 收藏

AppWidget的初始化有两种方式:

  1. 没有提供Configure Activity, 则在 AppWidgetProvider#onUpdate 里初始化。
  2. 提供Configure Activity, 则在 Configure Activity 里初始化。

目前遇到的问题是:

在Launcher里可以预先配置桌面显示的AppWidget,如果AppWidget有Configure Activity,则系统在AppWidget的初始化过程不会发送android.appwidget.action.APPWIDGET_CONFIGURE Intent,而只是加载appwidget-provider里配置的initialLayout。这样第二种就不可用,只能用第一种方法。

posted @ 2010-08-24 11:11 Eros 阅读(426) | 评论 (0)编辑 收藏

1.字体大小

synchronized void
setTextSize(WebSettings.TextSize t)

Set the text size of the page.

2.缩放比例

void
setSupportZoom(boolean support)

Set whether the WebView supports zoom

void
setInitialScale(int scaleInPercent)

Set the initial scale for the WebView.

boolean
zoomIn()

Perform zoom in in the webview

boolean
zoomOut()

Perform zoom out in the webview

3.缩放控件

void
setBuiltInZoomControls(boolean enabled)

Sets whether the zoom mechanism built into WebView is used.

4.JavaScript支持

synchronized void
setJavaScriptEnabled(boolean flag)

Tell the WebView to enable javascript execution.

posted @ 2010-07-28 12:49 Eros 阅读(381) | 评论 (0)编辑 收藏

在程序里备份恢复数据

public static boolean backupDatabase() {
    File dbFile = new File(Environment.getDataDirectory() + "/data/" + PKG + "/databases/" + DB_NAME);
 
    File exportDir = new File(Environment.getExternalStorageDirectory(), "pocket-voa");
    
    if (!exportDir.exists()) {
        exportDir.mkdirs();
    }
    
    File file = new File(exportDir, dbFile.getName());
 
    try {
        file.createNewFile();
        copyFile(dbFile, file);
        return true;
    } catch (IOException e) {
        Log.e(TAG, "[backupDatabase] error", e);
        return false;
    }
}
 
public static boolean restoreDatabase() {
    File dbFile = new File(Environment.getDataDirectory() + "/data/" + PKG + "/databases/" + DatabaseHelper.DB_NAME);
 
    File exportDbFile = new File(Environment.getExternalStorageDirectory() + "/pocket-voa/" + DatabaseHelper.DB_NAME);
    
    if (!exportDbFile.exists())
        return false;
 
    try {
        dbFile.createNewFile();
        copyFile(exportDbFile, dbFile);
        return true;
    } catch (IOException e) {
        Log.e(TAG, "[restoreDatabase] error", e);
        return false;
    }
}
 
private static void copyFile(File src, File dst) throws IOException {
    FileChannel inChannel = new FileInputStream(src).getChannel();
    FileChannel outChannel = new FileOutputStream(dst).getChannel();
    try {
        inChannel.transferTo(0, inChannel.size(), outChannel);
    } finally {
        if (inChannel != null)
            inChannel.close();
        if (outChannel != null)
            outChannel.close();
    }
}

参考

posted @ 2010-07-26 17:24 Eros 阅读(336) | 评论 (0)编辑 收藏

 

There are certain events that Android does not want to start up new processes for, so the device does not get too slow from all sorts of stuff all having to run at once. ACTION_SCREEN_ON is one of those. See this previous question for light blue advice on that topic.

So, you need to ask yourself, "Self, do I really need to get control on those events?". The core Android team would like it if your answer was "no".

posted @ 2010-07-22 19:59 Eros 阅读(1167) | 评论 (0)编辑 收藏
     摘要: 1.海词 http://api.dict.cn/ws.php?utf8=true&q=#{word} 返回格式XML<?xml version="1.0" encoding="UTF-8" ?> <dict> <key>word</key> <lang>ec</lang> <audio>...  阅读全文
posted @ 2010-07-15 15:45 Eros 阅读(2028) | 评论 (0)编辑 收藏

打开终端输入

adb devices

出现如下内容

??????????? no permissions

原因是启动adb的时候需要有root权限。如果一开始忘记加了sudo, 就必须先终止adb。

$ adb kill-server

$ sudo adb start-server

$ adb devices

就可以看到设备信息了。

参考

posted @ 2010-07-07 15:44 Eros 阅读(592) | 评论 (0)编辑 收藏
     摘要: 原理 关闭APN的原理是在APN信息表(content://telephony/carriers/current)的apn, type字段添加自定义的后缀(参考自APNDroid) 代码 (取自 Quick Settings) package com.android.settings.widget; import android.content.ContentResolver;impo...  阅读全文
posted @ 2010-07-07 15:28 Eros 阅读(718) | 评论 (0)编辑 收藏

环境

Ubuntu 9.10 64bit, sun-jdk-1.5(因需要编译Android源代码), Android SDK 2.1

症状

draw9patch 不能正确显示出窗口,没有菜单栏

原因

sun jdk 1.5 的BUG

解决

安装 sun jdk 1.6

参考

  1. http://resources2.visual-paradigm.com/index.php/tips-support/53-support/61-blank-screen.html
  2. http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6585673
  3. https://bugs.launchpad.net/ubuntu/+bug/164004
  4. http://forums.visual-paradigm.com/posts/list/6719.html
posted @ 2010-07-07 12:19 Eros 阅读(269) | 评论 (0)编辑 收藏

Install Ubuntu 9.10


Links

  1. http://docs.google.com/fileview?id=0B7vaQCSPJU8PNjUzZmU1ZTItYTVlNi00ZDBmLWFhMzMtN2Q3NDA4MzljMjRm&hl=zh_CN
  2. http://ubuntuabc.com/123/?p=38

Install JDK

sudo apt-get install sun-java6-jdk

sudo update-alternatives –config java


posted @ 2010-07-02 19:58 Eros 阅读(289) | 评论 (0)编辑 收藏

1.NPR News

http://code.google.com/p/npr-android-app/

image

2.Quick Settings

Quick Settings is a highly customizable all-in-one settings applications for Android.

http://code.google.com/p/quick-settings/

image

3.Quick Battery

http://code.google.com/p/quick-settings/source/browse/#svn/trunk/quick-battery

posted @ 2010-07-01 18:52 Eros 阅读(142) | 评论 (0)编辑 收藏