Free Projects developed by Java, C# and PHP

Call Log Manager app


We have many web application and mobile applications in GitHub for public use.

This project specifically developed to show how we can implement a simple 
android application to access and manage call logs on an android device 
in Android Studio with Java.

The project contains 1 main activity described below:
	- Call Log Activity: is used to demonstrate how we can access and 
	  remove call logs for a specific phone number

--> activity_call_log.xml
====================================================================================================================================
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context="training.ecea.calllogmanager.CallLogActivity">


    <TextView
        android:id="@+id/textView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Phone Number" />

    <EditText
        android:id="@+id/txtPhoneNumber"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ems="10"
        android:inputType="number" />

    <Button
        android:id="@+id/btnClearLog"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:onClick="ClearSelectedPhoneFromCallLog"
        android:text="Clear Log" />
</LinearLayout>
====================================================================================================================================

--> Call Log Activity.java
====================================================================================================================================
package training.ecea.calllogmanager;

import android.Manifest;
import android.content.pm.PackageManager;
import android.provider.CallLog;
import android.support.v4.app.ActivityCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.Button;
import android.widget.EditText;

public class CallLogActivity extends AppCompatActivity {

    EditText txtPhoneNumber;
    Button btnClearLog;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_call_log);

        txtPhoneNumber = (EditText) findViewById(R.id.txtPhoneNumber);
        btnClearLog = (Button) findViewById(R.id.btnClearLog);
    }

    public void ClearSelectedPhoneFromCallLog(android.view.View btn) {
        String queryString = "NUMBER='" + txtPhoneNumber.getText().toString() + "'";
        if (ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_CALL_LOG) != 
			PackageManager.PERMISSION_GRANTED) {
            // TODO: Consider calling
            //    ActivityCompat#requestPermissions
            // here to request the missing permissions, and then overriding
            //   public void onRequestPermissionsResult(int requestCode, String[] permissions,
            //                                          int[] grantResults)
            // to handle the case where the user grants the permission. See the documentation
            // for ActivityCompat#requestPermissions for more details.
            return;
        }

        this.getContentResolver().delete(CallLog.Calls.CONTENT_URI, queryString, null);
    }
}
====================================================================================================================================