Call logs

Additional

Language
Java
Version
1.09 (Jan 27, 2017)
Created
Oct 9, 2016
Updated
Jan 14, 2019
Owner
Yusuph Wickama (wickerlabs)
Contributor
Yusuph Wickama (wickerlabs)
1
Activity
Badge
Generate
Download
Source code
APK file

Advertising

Call Logs - Android library for accessing device call logs

Installation

Step 1. Add the JitPack repository to your root build.gradle file.

allprojects {
 repositories {
  ...
  maven { url "https://jitpack.io" }
 }
}

Step 2. Add the library dependency to your app build.gradle file

dependencies {
        implementation 'com.github.wickerlabs:CallLogs:1+@aar'
}

Step 3. Handle permissions (For API 23+)

For those targeting API 23+, 
you should handle the runtime permissions for READ_CONTACTS and READ_CALL_LOG. 
As a reference, check  out the sample app in the repository. 
Other than that, permissions are automatically added to the manifest file.

Usage

  • Initialization

    LogsManager logsManager = new LogsManager(context);
  • Getting a list of call logs

    List<LogObject> callLogs = logsManager.getLogs(type);
  • Available list types :

    LogsManager.INCOMING_CALLS: for getting the list (LogObject) of all the incoming calls.

    LogsManager.OUTGOING_CALLS: for getting the list (LogObject) of all the incoming calls.

    LogsManager.MISSED_CALLS: for getting the list (LogObject) of all the incoming calls.

    LogsManager.ALL_CALLS: for getting the list (LogObject) of all the calls.

  • Getting call durations

logsManager.getIncomingDuration(): returns the number of seconds for all the incoming calls made.

logsManager.getOutgoingDuration(): returns the number of seconds for all the outgoing calls made.

logsManager.getTotalDuration(): returns the number of seconds for all the calls made.

logsManager.getCoolDuration(type): returns a String in the form of "x hrs xx mins" or "xx mins xx secs"

  • Available duration types :

    LogsManager.INCOMING: for getting duration for all the incoming calls.

    LogsManager.OUTGOING: for getting duration for all the incoming calls.

    LogsManager.TOTAL: for getting duration for all the calls.

Using LogObjects

  • Some useful methods

logObject.getDuration(): returns an int of the seconds used for that particular call.

logObject.getNumber(): returns a String of the number associated with the call made.

logObject.getContactName(): returns a String of the contact name for the number in the log, if not found, it returns the number.

logObject.getType(): returns an int for the type of the call log.

logObject.getCoolDuration(): returns a String in the form of "x hrs xx mins" or "xx mins xx secs" based on the duration.

Examples

  • Retriving a list of all call logs:

     ListView logList = (ListView) findViewById(R.id.LogsList);
     LogsManager logsManager = new LogsManager(this);
     List<LogObject> callLogs = logsManager.getLogs(LogsManager.ALL_CALLS);
     LogsAdapter logsAdapter = new LogsAdapter(this, R.layout.log_layout, callLogs);
     logList.setAdapter(logsAdapter);

be sure to check out the sample app in the repository.

Acknowledgements

Icons made by madebyoliver from www.flaticon.com