私はアンドロイドアプリに取り組んでおり、着信不在着信を増やす必要があります。
ContentObserver を登録しました。通話が不在着信かどうかを onChange メソッドで確認するにはどうすればよいですか?
次のコードを含む contentobserver があります。
public class IncomingCall extend BroadcastReceiver
{
public void onReceive( final Context context, Intent intent)
{
String state= extras.getString(TelephonyManager.EXTRA_STATE);
if (TelephonyManager.EXTRA_STATE_IDLE.equals(state))
{
context.getApplicationContext().getContentResolver().registerContentObserver(android.provider.CallLog.Calls.CONTENT_URI, true, new CallContentObserver(new Handler(), context));
}
}
class CallContentObserver extends ContentObserver {
Context context;
public CallContentObserver(Handler handler, Context context) {
super(handler);
this.context = context;
}
@Override
public boolean deliverSelfNotifications() {
return true;
}
@Override
public void onChange(boolean selfChange) {
super.onChange(selfChange);
//flag for missed calls
how to check if last call is missed call?
Cursor c = context.getContentResolver().query(CallLog.Calls.CONTENT_URI,null,null, null, null);
int type = c.getColumnIndex(CallLog.Calls.TYPE);
while (c.moveToNext()) {
String callType = c.getString(type);
int dircode = Integer.parseInt(callType);
switch (dircode) {
case CallLog.Calls.MISSED_TYPE:
flag++;
}
break;
}
}
これを行う別の方法はありませんか?(CallLog データベースから最後の通話を確認したときよりも良いですか?