发送短信以拨打未接来电

时间:2012-04-19 07:00:35

标签: android

我想开发一个应用程序,在收到错过的时候发送消息     call.but我有一个问题,当我开始将短信发送到以前的活动     如何解决这个问题,我有一个小小的想法,一个特定的未接来电集     阅读或删除它其他明智的我的应用程序必须访问错过未接来电我     特定的时间    尝试{

        cursor = getContentResolver().query(
                Uri.parse("content://call_log/calls"),
                projection,
                selection,
                selectionArgs,
                sortOrder);
       // cursor.getString(cursor.getColumnIndex(android.provider.CallLog.Calls.MISSED_TYPE));
        while (cursor.moveToNext()) { 
            String callLogID = cursor.getString(cursor.getColumnIndex(android.provider.CallLog.Calls._ID));
            String callNumber = cursor.getString(cursor.getColumnIndex(android.provider.CallLog.Calls.NUMBER));
            String callDate = cursor.getString(cursor.getColumnIndex(android.provider.CallLog.Calls.DATE));
            String callType = cursor.getString(cursor.getColumnIndex(android.provider.CallLog.Calls.TYPE));
            String isCallNew = cursor.getString(cursor.getColumnIndex(android.provider.CallLog.Calls.NEW));
            //String missedcall= cursor.getString(cursor.getColumnIndex(android.provider.CallLog.Calls.MISSED_TYPE));
            /*if(Integer.parseInt(callType) == android.provider.CallLog.Calls.MISSED_TYPE && Integer.parseInt(isCallNew) > 0){
               tv.append("hai");
                //if (_debug) Log.v("Missed Call Found: " + callNumber);
            }*/

            if(cursor.getString(cursor.getColumnIndexOrThrow(android.provider.CallLog.Calls.TYPE)).equalsIgnoreCase("3") && Integer.parseInt(isCallNew)>0)
            {
                tv.append("ok"+callNumber+"\n");
                sm.sendTextMessage(callNumber, null, " iam in work i will call you later", null, null);
            }
        }
    }catch(Exception ex){
        //if (_debug) Log.e("ERROR: " + ex.toString());  

1 个答案:

答案 0 :(得分:0)

我猜你应该制作一个收听电话状态的广播接收器,如下所示:

broadcast receiver for missed call in android