android实用小工具

最近给手机写了个android实用工具,将一些用到的东西记下来.
工具就三个功能,1 自动向10086发送短信查询话费和流量 2 手电筒   3 建立了一些工程模式的快捷方式.

1 发短信首先要添加
<uses-permission android:name="android.permission.SEND_SMS"/>

这个权限,然后调用
SmsManager manager = SmsManager.getDefault();
manager.sendTextMessage(MOBILE_NUMBER, null, MOBILE_BALANCE, null,null);

即可

2 手电筒首先在activity里调用
this.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

用来保持屏幕常亮,屏幕的亮度可以用WindowManager.LayoutParams的screenBrightness大小来调节
http://developer.android.com/reference/android/view/WindowManager.LayoutParams.html#screenBrightness
而且本来网上说可以取消手机自带的亮度调节的,
  Settings.System.putInt(activity.getContentResolver(),
                Settings.System.SCREEN_BRIGHTNESS_MODE,
                Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL);

不过加了这行代码,在测试手机(三星 I9100)上报错了.

3 android手机的secret code调用
原来android手机有所谓的secret code,就是在拨号界面输入*#06#这种的,
SpecialCharSequenceMgr这个类负责把这样的secret code捕获,然后发出一个特定的Intent
   int len = input.length();
        if (len > 8 && input.startsWith("*#*#") && input.endsWith("#*#*")) {
            Intent intent = new Intent(Intents.SECRET_CODE_ACTION,
                    Uri.parse("android_secret_code://" + input.substring(4, len - 4)));
            context.sendBroadcast(intent);
            return true;
        }


也就是说,想达到*#*#4636#*#*这个拨号目的,直接发出一个对应的Intent就行.

我觉得*#*#0*#*#*这个还是比较有用的,最起码可以用来检查坏点.
比较完整的secret code可以看这里
http://tech.chinaunix.net/a2011/0124/1153/000001153400.shtml

猜你喜欢

转载自kabike.iteye.com/blog/1784690