を動作しません。例えば、このためのダイアログを選択:
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button btnPick = (Button) findViewById(R.id.btnPick);
btnPick.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
String[] strFields = { android.provider.CallLog.Calls._ID,
android.provider.CallLog.Calls.NUMBER,
android.provider.CallLog.Calls.CACHED_NAME, };
String strOrder = android.provider.CallLog.Calls.DATE + " DESC";
final Cursor cursorCall = getContentResolver().query(
android.provider.CallLog.Calls.CONTENT_URI, strFields,
null, null, strOrder);
AlertDialog.Builder builder = new AlertDialog.Builder(
MainActivity.this);
builder.setTitle("Select recent contact");
android.content.DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialogInterface,
int item) {
cursorCall.moveToPosition(item);
Toast.makeText(
MainActivity.this,
cursorCall.getString(cursorCall
.getColumnIndex(android.provider.CallLog.Calls.NUMBER)),
Toast.LENGTH_LONG).show();
cursorCall.close();
return;
}
};
builder.setCursor(cursorCall, listener,
android.provider.CallLog.Calls.CACHED_NAME);
builder.create().show();
}
});
}
}
http://stackoverflow.com/questions/6446580/android-get-call-history-of-contact?answertab=active#tab-top – Pasha