Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/**
 * Copyright (C) 2010-2012 Regis Montoya (aka r3gis - www.r3gis.fr)
 * This file is part of CSipSimple.
 *
 *  CSipSimple is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *  If you own a pjsip commercial license you can also redistribute it
 *  and/or modify it under the terms of the GNU Lesser General Public License
 *  as an android library.
 *
 *  CSipSimple is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with CSipSimple.  If not, see <http://www.gnu.org/licenses/>.
 */

import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.provider.CallLog;

public class Main {
    private static final String ACTION_ANNOUNCE_SIP_CALLLOG = "de.ub0r.android.callmeter.SAVE_SIPCALL";
    private static final String EXTRA_CALL_LOG_URI = "uri";
    public static final String EXTRA_SIP_PROVIDER = "provider";

    public static void addCallLog(Context context, ContentValues values, ContentValues extraValues) {
        ContentResolver contentResolver = context.getContentResolver();
        Uri result = contentResolver.insert(CallLog.Calls.CONTENT_URI, values);

        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);
        }
    }
}