这是java代码:
public class ReadContactActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button queBtn = (Button)findViewById(R.id.query);
queBtn.setOnClickListener(new OnClickListener()
{
public void onClick(View v)
{
readContact();
}
}
);
}
public void readContact()
{
Cursor cursor = this.getContentResolver().query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null);
while(cursor.moveToFirst())
{
int index = cursor.getColumnIndex(PhoneLookup.DISPLAY_NAME);
String name = cursor.getString(index);
Toast.makeText(this, name, Toast.LENGTH_SHORT).show();
}
}
}这是描述文件:请高手看看是哪里不对?运行的时候出现出错!
public class ReadContactActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button queBtn = (Button)findViewById(R.id.query);
queBtn.setOnClickListener(new OnClickListener()
{
public void onClick(View v)
{
readContact();
}
}
);
}
public void readContact()
{
Cursor cursor = this.getContentResolver().query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null);
while(cursor.moveToFirst())
{
int index = cursor.getColumnIndex(PhoneLookup.DISPLAY_NAME);
String name = cursor.getString(index);
Toast.makeText(this, name, Toast.LENGTH_SHORT).show();
}
}
}这是描述文件:请高手看看是哪里不对?运行的时候出现出错!
解决方案 »
- Android 多个 button 自动换行布局问题.
- 两个apk之间通过广播进行通信 请问能取得返回值吗?
- 新浪微博客户端---授权认证出错啦,求大家帮帮忙
- Android EGL_BAD_ALLOC 的问题,有没有遇到并很好的解决了?
- 求大神帮忙!传参问题!!
- 如何在指定主题下显示想要的DatePickerDialog样式
- 静读天下无法访问calibre书库
- progressDialog 为什么设置了setProgress()方法无反应?
- Android布局问题
- android网页分享到朋友圈问题求助?
- OOM bitmap size exceeds VM budget 处理
- 三维Json怎么解析
如果是要查找一次查找全部信息 上面的uri就不行了
要用到 PhoneLookup.content_filter_uri