博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

2011年5月16日

摘要: public boolean checkShortcut(){ boolean isInstallShortcut = false ; final ContentResolver cr =this.getContentResolver(); final String AUTHORITY = "com.android.launcher.settings"; final Uri CONTENT_URI... 阅读全文

posted @ 2011-05-16 23:02 QQ石头 阅读(442) 评论(0) 推荐(0)

摘要: 1.在Android中编写Service,需要继承android.app.Service,覆盖其onCreate()和onStart(Intent intent, int startId)方法即可,onCreate方法只在service创建时调用,onStart方法每次都会调用。2.在Service中不能直接访问数据库,只能通过ContentResolver访问,如果访问自己的数据,需要继承Con... 阅读全文

posted @ 2011-05-16 00:09 QQ石头 阅读(535) 评论(1) 推荐(1)

2011年5月15日

摘要: 在android编写Service入门中介绍了android的两种后台服务,本地和远程的。这里用本地服务做了一个模拟定时后台发短信的技术原型。启动该示例应用的样子:选择启动:启动后,可看到ddms logcat日志:这是操作:启动、停止和退出应用,显示的调试日志信息。模拟后台服务每5秒钟发送一次短信信息。主要代码,后台服务SmsService: package com.easymorse; imp... 阅读全文

posted @ 2011-05-15 16:59 QQ石头 阅读(2967) 评论(0) 推荐(0)

摘要: 应用程序窗口小部件App Widgets应用程序窗口小部件(Widget)是微小的应用程序视图,可以被嵌入到其它应用程序中(比如桌面)并接收周期性的更新。你可以通过一个App Widget provider来发布一个Widget。可以容纳其它App Widget的应用程序组件被称为App Widget宿主。下面的截屏显示了一个音乐App Widget。这篇文章描述了如何使用App Widget P... 阅读全文

posted @ 2011-05-15 09:10 QQ石头 阅读(1892) 评论(0) 推荐(1)

2011年5月14日

摘要: 在Android系统中,所有安装到系统的应用程序都必有一个数字证书,此数字证书用于标识应用程序的作者和在应用程序之间建立信任关系,如果一个permission的protectionLevel为signature,那么就只有那些跟该permission所在的程序拥有同一个数字证书的应用程序才能取得该权限。Android使用Java的数字证书相关的机制来给apk加盖数字证书,要理解android的数字... 阅读全文

posted @ 2011-05-14 23:49 QQ石头 阅读(1553) 评论(0) 推荐(1)

摘要: /*** 为程序创建桌面快捷方式*/private void addShortcut(){Intent shortcut = new Intent(“com.android.launcher.action.INSTALL_SHORTCUT”);//快捷方式的名称shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.app_... 阅读全文

posted @ 2011-05-14 22:08 QQ石头 阅读(575) 评论(0) 推荐(0)

摘要: Notification可以在屏幕最顶部的状态栏上显示一个图标通知(QQ用的就是这个),通知的同时可以播放声音,以及振动提示用户,点击通知还可以返回指定的Activity.例子的效果图:下面我们来实现。布局main.xml:<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical&quo 阅读全文

posted @ 2011-05-14 21:29 QQ石头 阅读(794) 评论(0) 推荐(0)

摘要: When i was looking at the strace output closely. I noticed a service named android.telephony.PhoneNotifier. It stuck somewhere in my head. A few(?) days later i ran info the android.os.Mailbox class. Another few days later, when poking into the dexdump output of Phone.apk, it all came together. Here 阅读全文

posted @ 2011-05-14 02:02 QQ石头 阅读(263) 评论(0) 推荐(0)

摘要: Android来电号码获取的方法很简单,虽然Dalvik上的程序都是Java写的,但是仍然可以处理系统事物,使用 PhoneStateListener;类可以监测话机状态,而TelephonyManager可以获取电话服务的实例,写代码时不要忘了在 androidmanifest.xml中加入权限。需要引入两个Packageimport android.telephony.PhoneStateListener;import android.telephony.TelephonyManager;MyPhoneStateListener phoneListener=new MyPhoneState 阅读全文

posted @ 2011-05-14 01:53 QQ石头 阅读(1151) 评论(0) 推荐(0)

摘要: File IO works fine on Android using JNI. Perhaps you are trying to open a file with a bad path and not checking the return code? I modified the hello-jni example to demonstrate that it is indeed possible to open file and write to it. I hope this helps./* * Copyright (C) 2009 The Android Open Source 阅读全文

posted @ 2011-05-14 01:51 QQ石头 阅读(1684) 评论(0) 推荐(0)