I just want to copy the incoming number and paste it to a text box. How can I do that?
Asked
Active
Viewed 509 times
0
-
You need to tell a bit about what you have investigated to do that. – cmbarbu Mar 24 '15 at 10:22
-
You have to register one Broadcast Receiver to receive incoming number and from receiver you can get number.see this link it may helpful http://stackoverflow.com/questions/13154445/how-to-get-phone-number-from-an-incoming-call – Hanuman Mar 24 '15 at 10:24
1 Answers
0
Use a cursor to get any call log information you want.
String[] projection = {android.provider.CallLog.Calls._ID,
android.provider.CallLog.Calls.NUMBER,
CallLog.Calls.TYPE, CallLog.Calls.DATE};
final Cursor cursor = getActivity().getContentResolver().query(
android.provider.CallLog.Calls.CONTENT_URI, projection,
"type = " + CallLog.Calls.INCOMING_TYPE, null,
android.provider.CallLog.Calls.DATE + " DESC" + " LIMIT 200");
The cursor will result the number and time of call.
if (cursor.moveToFirst()) {
do {
try {
String number = cursor.getString(cursor.getColumnIndex(CallLog.Calls.NUMBER));
String date = cursor.getString(cursor.getColumnIndex(CallLog.Calls.DATE));
// Do anything with number and name
} catch (Exception e) {
}
} while (cursor.moveToNext());
}
cursor.close();

VipulKumar
- 2,385
- 1
- 22
- 28