works on emulator (don't forget permission android.permission.READ_CONTACTS and android.permission.READ_PHONE_STATE):leftysloft wrote:...
I am having great difficulty with the caller ID (lack of understanding).
...
Code: Select all
} else if(intent.getAction().equals("android.intent.action.PHONE_STATE")){
// but just if RING?
Toast.makeText(context,"android.intent.action.PHONE_STATE", Toast.LENGTH_LONG).show();
String Num = intent.getStringExtra(EXTRA_INCOMING_NUMBER);
String Name = Num;
Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(Num));
Cursor cur = context.getContentResolver().query(uri,
new String[] { PhoneLookup.DISPLAY_NAME },
null, null, null );
if( cur.moveToFirst() ) {
int nameIdx = cur.getColumnIndex(PhoneLookup.DISPLAY_NAME);
Name = cur.getString(nameIdx);
}
Intent mSendToSamy = new Intent(context, SendToSamy.class);
mSendToSamy.putExtra("message_from", "Incoming Call");
mSendToSamy.putExtra("message", "Call from: " + Name + "(" + Num + ")");
mSendToSamy.putExtra("category", "Incoming Call");
context.sendBroadcast(mSendToSamy);
} else {
arris