Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6043357
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:53:30+00:00 2026-05-23T06:53:30+00:00

I have just started with phoneGap and Android. Built basic samples. I would like

  • 0

I have just started with phoneGap and Android. Built basic samples.

I would like to know, if there is an API to get the call logs. I wish to create a grid showing:

  • Number of missed calls over a period of time
  • Number of received calls
  • Number of calls made
  • Total time of the received calls and calls made

Thanks in advance.

  • 1 1 Answer
  • 3 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T06:53:31+00:00Added an answer on May 23, 2026 at 6:53 am

    I did a bit of research and has successfully built a PhoneGap plugin which would fetch the CallLog from android.provider.CallLog.

    This returns an JSON { Rows: [] } where Rows is an 2 dimensional array of call records containing the following fields (as Array) in the following order :

    • Date (as UNIX Time stamp)
    • Number,
    • Type (1- incoming, 2- outgoing, 3- missed)
    • Duration (in seconds)
    • New
    • Cached Name
    • Cached number type
    • Cached number label

    Details are in http://developer.android.com/reference/android/provider/CallLog.Calls.html

    I have also made a small sample using this plugin which would show total number of outgoing calls, missed calls and incoming calls and plot them in a Pie chart. The sample is using FusionCharts’ Pie chart.

    You can download a beta try-out .apk from :

    http://www.sudipto.net/download/android/apps/CallLog/beta/CallChart.apk.zip

    (using JavaScript SVG charts that works in Android version 3 or above)

    Here is the source-code zip for you to delve into:

    http://www.sudipto.net/download/android/apps/CallLog/beta/calllog_phonegap_eclipseclassic_source.zip

    Here is my complete code:

    CallLog.java

    package com.fusioncharts.phonegap.plugin;
    
    import org.json.*;
    
    import android.database.*;
    import android.util.Log;
    
    import com.phonegap.api.Plugin;
    import com.phonegap.api.PluginResult;
    import com.phonegap.api.PluginResult.Status;
    
    public class CallLog extends Plugin {
    
            @Override
            public PluginResult execute(String actionName, JSONArray arguments, String callback) 
            {
    
    
                    JSONObject callLogs = new JSONObject();
                    PluginResult result = null;
    
    
                    try {
                            switch (getActionItem(actionName))
                            {
                                    case 1:
                                            callLogs = getAllCallLog(arguments);
                                            result = new PluginResult(Status.OK, callLogs);
                                            break;
                                    default:
                                            result = new PluginResult(Status.INVALID_ACTION);
                            }
                    } catch (JSONException jsonEx) {
                            result = new PluginResult(Status.JSON_EXCEPTION);
                    }
    
    
    
                    return result;
            }
    
    
            private JSONObject getAllCallLog(JSONArray requirements) throws JSONException
            {
                    JSONObject callLog = new JSONObject();
    
                    String[] strFields = {
                            android.provider.CallLog.Calls.DATE,
                            android.provider.CallLog.Calls.NUMBER, 
                            android.provider.CallLog.Calls.TYPE,
                            android.provider.CallLog.Calls.DURATION,
                            android.provider.CallLog.Calls.NEW,
                            android.provider.CallLog.Calls.CACHED_NAME,
                            android.provider.CallLog.Calls.CACHED_NUMBER_TYPE,
                            android.provider.CallLog.Calls.CACHED_NUMBER_LABEL//,
                    };
    
                    try {
                            Cursor callLogCursor = ctx.getContentResolver().query(
                                    android.provider.CallLog.Calls.CONTENT_URI,
                                    strFields,
                                    null,
                                    null,
                                    android.provider.CallLog.Calls.DEFAULT_SORT_ORDER
                                );
    
    
    
                    int callCount = callLogCursor.getCount();
    
                    if(callCount>0){
                            JSONArray callLogItem = new JSONArray();
                            JSONArray callLogItems = new JSONArray();
    
                            String[] columnNames = callLogCursor.getColumnNames();
    
                            callLogCursor.moveToFirst();
                            do
                            {
                                    callLogItem.put(callLogCursor.getLong(0));
                                    callLogItem.put(callLogCursor.getString(1));
                                    callLogItem.put(callLogCursor.getInt(2));
                                    callLogItem.put(callLogCursor.getLong(3));
                                    callLogItem.put(callLogCursor.getInt(4));
                                    callLogItem.put(callLogCursor.getString(5));
                                    callLogItem.put(callLogCursor.getInt(6));
                                    callLogItems.put(callLogItem);
                                    callLogItem = new JSONArray();
    
                            }while(callLogCursor.moveToNext());
    
                            callLog.put("Rows", callLogItems);
                    }
    
    
                    callLogCursor.close();
                    }catch(Exception e)
                    {
    
                            Log.d("CallLog_Plugin", " ERROR : SQL to get cursor: ERROR " + e.getMessage());
                    }
    
    
    
                    return callLog;
            }
    
            private JSONObject getTimeRangeCallLog(JSONArray requirements)
            {
    
            private int getActionItem(String actionName) throws JSONException 
            {
                    JSONObject actions = new JSONObject("{'all':1,'last':2,'time':3}");
                    if (actions.has(actionName))
                            return actions.getInt(actionName);
    
                    return 0;
            }
    }
    

    calllog.phonegap.js

        var CallLog = function() {};
        CallLog.prototype.all = function(params, successCallback, failureCallback) 
        {
            return PhoneGap.exec(successCallback, failureCallback, 'CallLog', 'all', [params]);
        };
    
        PhoneGap.addConstructor( function() {
              PhoneGap.addPlugin("calllog", new CallLog());
              PluginManager.addService("CallLog","com.fusioncharts.phonegap.plugin.CallLog");
        });
    

    Application.java

    var CallLog = function() {};
    CallLog.prototype.all = function(params, successCallback, failureCallback) 
    {
        /* @param   successCallback
         * @param   failureCallback
         * @param   plugin name
         * @param   action
         * @param   JSONArray of parameters
         */ 
        return PhoneGap.exec(successCallback, failureCallback, 'CallLog', 'all', [params]);
    };
    
    PhoneGap.addConstructor( function() {
          //Register the javascript plugin with PhoneGap
          PhoneGap.addPlugin("calllog", new CallLog());
    
          //Register the native class of plugin with PhoneGap
          PluginManager.addService("CallLog","com.fusioncharts.phonegap.plugin.CallLog");
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just started learning Lucene and would like to use it for indexing
I have just started looking into using Modules in Flex and would like to
Have just started using Visual Studio Professional's built-in unit testing features, which as I
I have just started using Boost 1.36. These libraries would be very useful in
I have just started working with nodejs. I wonder if there is a way
I have just started using services in Android and I have a made a
i have just started learning linq because i like the sound of it. and
I'm trying to get started with Phonegap. I have added some code to applicationDidFinishLaunching
I have just started using ActionScript. and i want to know the Lifecycle of
i have just started programming for android and i have a little question i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.