0

我想开发一个应用程序,在收到未接来电时发送消息。但是当我开始向以前的人发送短信的活动时,我遇到了问题如何解决这个问题,我有一个小想法那个特定的未接电话被读取或删除,否则我的应用程序必须在特定的时间段内访问未接的未接电话尝试{

        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());  
4

1 回答 1

0

我想你应该制作一个像这样监听电话状态的广播接收器:

android中未接来电的广播接收器

于 2012-04-19T07:20:38.233 回答