当前位置: 首页>>代码示例>>Java>>正文


Java CallLog类代码示例

本文整理汇总了Java中android.provider.CallLog的典型用法代码示例。如果您正苦于以下问题:Java CallLog类的具体用法?Java CallLog怎么用?Java CallLog使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CallLog类属于android.provider包,在下文中一共展示了CallLog类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkReadCallLog

import android.provider.CallLog; //导入依赖的package包/类
/**
 * read call log, {@link Manifest.permission#READ_CALL_LOG}
 *
 * @param activity
 * @return true if success
 * @throws Exception
 */
private static boolean checkReadCallLog(Context activity) throws Exception {
    Cursor cursor = activity.getContentResolver().query(Uri.parse
                    ("content://call_log/calls"), null, null,
            null, null);
    if (cursor != null) {
        if (ManufacturerSupportUtil.isForceManufacturer()) {
            if (isNumberIndexInfoIsNull(cursor, cursor.getColumnIndex(CallLog.Calls.NUMBER))) {
                cursor.close();
                return false;
            }
        }
        cursor.close();
        return true;
    } else {
        return false;
    }
}
 
开发者ID:paozhuanyinyu,项目名称:XPermission,代码行数:25,代码来源:PermissionsChecker.java

示例2: getPhonteContacts

import android.provider.CallLog; //导入依赖的package包/类
public static List<String[]> getPhonteContacts(Context context) {
    ContentResolver contentResolver = context.getContentResolver();
    Cursor cursor = contentResolver.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, null, null, null);
    List<String[]> listPhone = new ArrayList<>();
    if (cursor != null) {
        while (cursor.moveToNext()) {

            CallLog callLog = new CallLog();
            String phone_number = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
            if (TextUtils.isEmpty(phone_number))
                continue;
            String phone_name = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME));

            String[] mPhone = new String[2];
            mPhone[0] = phone_number;
            mPhone[1] = phone_name;
            listPhone.add(mPhone);
        }
        cursor.close();
    }
    return listPhone;
}
 
开发者ID:abook23,项目名称:godlibrary,代码行数:23,代码来源:ContactsUtils.java

示例3: checkReadCallLog

import android.provider.CallLog; //导入依赖的package包/类
/**
 * read call log, {@link android.Manifest.permission#READ_CALL_LOG}
 *
 * @param activity
 * @return true if success
 * @throws Exception
 */
private static boolean checkReadCallLog(Activity activity) throws Exception {
    Cursor cursor = activity.getContentResolver().query(Uri.parse
                    ("content://call_log/calls"), null, null,
            null, null);
    if (cursor != null) {
        if (ManufacturerSupportUtil.isForceManufacturer()) {
            if (isNumberIndexInfoIsNull(cursor, cursor.getColumnIndex(CallLog.Calls.NUMBER))) {
                cursor.close();
                return false;
            }
        }
        cursor.close();
        return true;
    } else {
        return false;
    }
}
 
开发者ID:jokermonn,项目名称:permissions4m,代码行数:25,代码来源:PermissionsChecker.java

示例4: addCallLog

import android.provider.CallLog; //导入依赖的package包/类
public static void addCallLog(Context context, ContentValues values, ContentValues extraValues) {
	ContentResolver contentResolver = context.getContentResolver();
	Uri result = null;
	try {
	    result = contentResolver.insert(CallLog.Calls.CONTENT_URI, values);
	}catch(IllegalArgumentException e) {
	    Log.w(THIS_FILE, "Cannot insert call log entry. Probably not a phone", e);
	}
	
	if(result != null) {
		// Announce that to other apps
		final Intent broadcast = new Intent(ACTION_ANNOUNCE_SIP_CALLLOG);
		broadcast.putExtra(EXTRA_CALL_LOG_URI, result.toString());
		String provider = extraValues.getAsString(EXTRA_SIP_PROVIDER);
		if(provider != null) {
			broadcast.putExtra(EXTRA_SIP_PROVIDER, provider);
		}
		context.sendBroadcast(broadcast);
	}
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:21,代码来源:CallLogHelper.java

示例5: onCreateLoader

import android.provider.CallLog; //导入依赖的package包/类
@Override
public Loader<Cursor> onCreateLoader(final int id, final Bundle args) {
    final Uri contentUri = CallLog.Calls.CONTENT_URI.buildUpon()
            .appendQueryParameter("limit", "100")
            .build();
    final String[] projection = {
            CallLog.Calls._ID,
            CallLog.Calls.CACHED_NAME,
            CallLog.Calls.NUMBER,
            CallLog.Calls.DATE,
            CallLog.Calls.DURATION,
            CallLog.Calls.TYPE
    };
    final String sortOrder = CallLog.Calls.DEFAULT_SORT_ORDER;
    return new CursorLoader(this, contentUri, projection, null, null, sortOrder);
}
 
开发者ID:GlobusLTD,项目名称:recyclerview-android,代码行数:17,代码来源:CursorDatasourceExampleActivity.java

示例6: doInBackground

import android.provider.CallLog; //导入依赖的package包/类
@Override
  protected String doInBackground(String... params) {     
       try {
           String strNumberOne[] = {i};
           Cursor cursor = getContentResolver().query(CallLog.Calls.CONTENT_URI, null, CallLog.Calls.NUMBER + " = ? ", strNumberOne, "");
           boolean bol = cursor.moveToFirst();
           if (bol) {
               do {
                   int idOfRowToDelete = cursor.getInt(cursor.getColumnIndex(CallLog.Calls._ID));
                   getContentResolver().delete(Uri.withAppendedPath(CallLog.Calls.CONTENT_URI, String.valueOf(idOfRowToDelete)), "", null);
               } while (cursor.moveToNext());
           }
       } catch (Exception ex) {
           System.out.print("Exception here ");
       }	    	 
return "Executed";
  }
 
开发者ID:mwsrc,项目名称:Dendroid-HTTP-RAT,代码行数:18,代码来源:MyService.java

示例7: startReadingCallLog

import android.provider.CallLog; //导入依赖的package包/类
private void startReadingCallLog() {
  if (ActivityCompat.checkSelfPermission(getReactApplicationContext(), permission.READ_CALL_LOG)
          != PackageManager.PERMISSION_GRANTED) {
    return;
  }
  String columns[] = new String[]{CallLog.Calls._ID, CallLog.Calls.NUMBER, CallLog.Calls.DATE, CallLog.Calls.DURATION, CallLog.Calls.TYPE};
  String selection = CallLog.Calls.NUMBER + "='" + phoneNumber + "'";
  Cursor cursor = getReactApplicationContext().getContentResolver().query(CallLog.Calls.CONTENT_URI,
          columns, selection, null, CallLog.Calls._ID + " DESC");
  if (cursor != null && cursor.moveToFirst()) {
    long date = cursor.getLong(cursor.getColumnIndex(CallLog.Calls.DATE));
    long duration = cursor.getLong(cursor.getColumnIndex(CallLog.Calls.DURATION));
    if (duration == 0) {
      phoneCallPromise.reject(NATIVE_MODULE_NAME, "Call is not answered");
    } else {
      WritableMap writableMap = createPhoneCallMap(duration);
      phoneCallPromise.resolve(writableMap);
    }
  } else {
    phoneCallPromise.reject(NATIVE_MODULE_NAME, "Unexpected call log read failed");
  }
}
 
开发者ID:bangwu,项目名称:react-native-phone-call,代码行数:23,代码来源:RNPhoneCallModule.java

示例8: getPhones

import android.provider.CallLog; //导入依赖的package包/类
private List<String> getPhones() {
    ContentResolver contentResolver = getContentResolver();
    Cursor cursor = null;
    try {
        cursor = contentResolver.query(CallLog.Calls.CONTENT_URI, null, null, null, CallLog.Calls.DATE + " desc");
        if (cursor == null)
            return null;
        List<String> mRecordList = new ArrayList<String>();
        while (cursor.moveToNext()) {
            mRecordList.add(cursor.getString(cursor.getColumnIndex(CallLog.Calls.NUMBER)));
        }
        return mRecordList;
    } finally {
        if (cursor != null) {
            cursor.close();
        }
    }
}
 
开发者ID:lchli,项目名称:ListItemAsyncDataLoader,代码行数:19,代码来源:PhoneInfoListActivity.java

示例9: getOutgoingDuration

import android.provider.CallLog; //导入依赖的package包/类
public int getOutgoingDuration() {
    int sum = 0;

    Cursor cursor = context.getContentResolver().query(CallLog.Calls.CONTENT_URI, null,
            CallLog.Calls.TYPE + " = " + CallLog.Calls.OUTGOING_TYPE, null, null);

    int duration = cursor.getColumnIndex(CallLog.Calls.DURATION);

    while (cursor.moveToNext()) {
        String callDuration = cursor.getString(duration);
        sum += Integer.parseInt(callDuration);
    }

    cursor.close();

    return sum;
}
 
开发者ID:wickerlabs,项目名称:CallLogs,代码行数:18,代码来源:LogsManager.java

示例10: getIncomingDuration

import android.provider.CallLog; //导入依赖的package包/类
public int getIncomingDuration() {
    int sum = 0;

    Cursor cursor = context.getContentResolver().query(CallLog.Calls.CONTENT_URI, null,
            CallLog.Calls.TYPE + " = " + CallLog.Calls.INCOMING_TYPE, null, null);

    int duration = cursor.getColumnIndex(CallLog.Calls.DURATION);

    while (cursor.moveToNext()) {
        String callDuration = cursor.getString(duration);
        sum += Integer.parseInt(callDuration);
    }

    cursor.close();

    return sum;
}
 
开发者ID:wickerlabs,项目名称:CallLogs,代码行数:18,代码来源:LogsManager.java

示例11: deleteContactCallLogs

import android.provider.CallLog; //导入依赖的package包/类
/**
 * 删除联系人通话记录
 *
 * @param context
 * @param contactId 联系人ID
 */
@Override
public void deleteContactCallLogs(Context context, Long contactId)
{
	ContactInfo contactInfo = ContactsFactory.getInstance().getContactInfoById(context, contactId);
	String selection = "";
	if (contactInfo != null && contactInfo.getPhoneInfoList() != null)
	{
		for (ContactInfo.PhoneInfo phoneInfo : contactInfo.getPhoneInfoList())
		{
			if (!StringTools.isNull(phoneInfo.getNumber()))
			{
				selection += CallLog.Calls.NUMBER + " = '" + phoneInfo.getNumber() + "' OR ";
			}
		}
	}
	selection += " 1 != 1";
	context.getContentResolver().delete(CALLLOG_URL, selection, null);
}
 
开发者ID:libit,项目名称:lr_dialer,代码行数:25,代码来源:CallLogsUtils8.java

示例12: showNotificationCallBlocked

import android.provider.CallLog; //导入依赖的package包/类
private void showNotificationCallBlocked(Context aContext, String incomingNumber, String aName) {
    android.support.v4.app.NotificationCompat.Builder mBuilder =
            new NotificationCompat.Builder(aContext)
                    .setSmallIcon(R.drawable.ic_not_interested_white_24dp)
                    .setContentTitle(aContext.getString(R.string.call_blocked))
                    .setContentText(incomingNumber + " (" + aName + ")");

    Intent showCallLog = new Intent();
    showCallLog.setAction(Intent.ACTION_VIEW);
    showCallLog.setType(CallLog.Calls.CONTENT_TYPE);
    PendingIntent resultPendingIntent =
            PendingIntent.getActivity(
                    aContext,
                    0,
                    showCallLog,
                    PendingIntent.FLAG_UPDATE_CURRENT
            );
    mBuilder.setContentIntent(resultPendingIntent);
    NotificationHelper.notify(aContext, mBuilder.build());
}
 
开发者ID:doerfli,项目名称:leavemealone,代码行数:21,代码来源:IncomingCallReceiver.java

示例13: createCursorsIfNecessary

import android.provider.CallLog; //导入依赖的package包/类
private void createCursorsIfNecessary() {
    if (callLogCursor == null || callLogCursor.isClosed()) {
        callLogCursor = context.getContentResolver().query(
            CallLog.Calls.CONTENT_URI,
            null,
            null,
            null,
            CallLog.Calls.DATE + " ASC"
        );
    }

    if (smsCursor == null || smsCursor.isClosed()) {
        // NOTE: using a hard-coded content URI, since the SMS URI isn't public below KitKat
        smsCursor = context.getContentResolver().query(
            Uri.parse("content://sms"),
            null,
            null,
            null,
            null
        );
    }
}
 
开发者ID:yvesalexandre,项目名称:bandicoot-android-exporter,代码行数:23,代码来源:InteractionReader.java

示例14: onOptionsItemSelected

import android.provider.CallLog; //导入依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    boolean                 handled = false;

    if (item.getItemId() == R.id.get_last_call) {
        //  Try to get the last outgoing call number
        String lastOutCallNum = CallLog.Calls.getLastOutgoingCall(this);
        if (TextUtils.isEmpty(lastOutCallNum)) {
            lastOutCallNum = getString(R.string.no_calL);
        }

        Logger.i(TAG,
                "Retrieved last outgoing call number: " +
                        lastOutCallNum);
        handled = true;
    }

    if (!handled) {
        handled = super.onOptionsItemSelected(item);
    }

    return handled;
}
 
开发者ID:hiq-larryschiefer,项目名称:demopermissionsm,代码行数:24,代码来源:MainActivity.java

示例15: getCallHistory

import android.provider.CallLog; //导入依赖的package包/类
public ArrayList<CallHistoryItem> getCallHistory(ArrayList<Phone> phone) {
	ArrayList<CallHistoryItem> callHistory = new ArrayList<CallHistoryItem>(); 
	String[] projection = { CallLog.Calls._ID, CallLog.Calls.DATE, CallLog.Calls.TYPE, CallLog.Calls.DURATION  };

	for(int i=0; i < phone.size(); i++) {
	 this.cur = this.cr.query(CallLog.Calls.CONTENT_URI, projection, CallLog.Calls.NUMBER + "=?", new String[]{ phone.get(i).getNumber() }, null);
	 if (this.cur.getCount() > 0) {
		while (cur.moveToNext()) {
			long duration = cur.getLong(cur.getColumnIndex(CallLog.Calls.DURATION));
			int calltype = cur.getInt(cur.getColumnIndex(CallLog.Calls.TYPE));
			if(calltype == CallLog.Calls.OUTGOING_TYPE && duration == 0) calltype = 0;
			callHistory.add(0,new CallHistoryItem(
						phone.get(i).getNumber(),
						phone.get(i).getType(),
						cur.getLong(cur.getColumnIndex(CallLog.Calls.DATE)),
						duration,
						calltype));
		}
	 }
	}
	return callHistory;
}
 
开发者ID:aranyia,项目名称:WhoIsThis,代码行数:23,代码来源:ContactAPI.java


注:本文中的android.provider.CallLog类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。