編輯:Android開發教程
Introduction To Android Contacts
Learn to work with the Android contacts database. Basic knowledge of accessing SQLite in Android along with using Cursors is expected. See the Android SQLite and Cursor Article for more information. Google changed the contacts database moving from 1.x to 2.0 versions of Android. This tutorial will be broken into 3 sections. First covering accessing contacts in Android 2.0. The second page will deal with accessing the contacts in Android 1.6 and before. Third we'll glue it all together with a class that abstracts specific classes for each version and a set of classes to manage the data from the contact records.
Contacts 讀取代碼:
package com.homer.phone; import java.util.ArrayList; import java.util.HashMap; import android.app.Activity; import android.database.Cursor; import android.os.Bundle; import android.provider.ContactsContract; import android.provider.ContactsContract.CommonDataKinds.Phone; import android.widget.ListView; import android.widget.SimpleAdapter; public class phoneRead extends Activity { @Override public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); showListView(); } private void showListView(){ ListView listView = new ListView(this); ArrayList<HashMap<String, String>> list = getPeopleInPhone2(); SimpleAdapter adapter = new SimpleAdapter( this, list, android.R.layout.simple_list_item_2, new String[] {"peopleName", "phoneNum"}, new int[]{android.R.id.text1, android.R.id.text2} ); listView.setAdapter(adapter); setContentView(listView); } private ArrayList<HashMap<String, String>> getPeopleInPhone2(){ ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>(); Cursor cursor = getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, null, null, null); // 獲取手機聯系人 while (cursor.moveToNext()) { HashMap<String, String> map = new HashMap<String, String>(); int indexPeopleName = cursor.getColumnIndex(Phone.DISPLAY_NAME); // people name int indexPhoneNum = cursor.getColumnIndex(Phone.NUMBER); // phone number String strPeopleName = cursor.getString(indexPeopleName); String strPhoneNum = cursor.getString(indexPhoneNum); map.put("peopleName", strPeopleName); map.put("phoneNum", strPhoneNum); list.add(map); } if(!cursor.isClosed()){ cursor.close(); cursor = null; } return list; } }
最近在考慮為已經有的一個應用程序增加一個用戶反饋的功能,用戶可以通過反饋功能將用戶的意見和建議、程序出現的問題以一種更符合用戶習慣的方式反饋回來。網上也有一些實現好的反饋
1.介紹快過年了,博主的新應用-屏幕取詞之了老花鏡的編碼工作也在緊鑼密鼓的進行中。下面分享一下這個應用中的核心功能ocr,也就是圖片識詞功能。先來看下我的實現效果。上圖是
這篇文章算是對整個引導界面開發專題的一個終結了吧,個人覺得大部分的引導界面基本上都是千篇一律 的,只要熟練掌握了一個,基本上也就沒什麼好說的了,要是在今後的開發中遇到了
這個話題是繼續android安全問題(二) 程序鎖延伸的之前我已經展示了如何制作程序鎖。當打 開指定應用的時候,彈出一個密碼頁面。程序鎖的話題雖然是和安全相關,但是這應該