1. Download the #1 Android News App:   EarlyBird - News for Android
    Dismiss Notice

how to deal with classes in android? help please

Last Updated:

  1. kwty

    kwty Member

    Hi guys,
    I'm working in a project and I want to create a class that has a cursor to retrieve the call log or contacts data and passes them to the main activity or print them or doing anything with them. The problem is when I want to deal with the getContentResolver() and StartManagingCursor(Cursor) they gave me errors. When I do the same application inside the main activity it works fine with me. I tried to extends the activity in the class the error is gone but the program isn't work. I really need to run this application in a separate class and call it inside the main activity so how can I handle this problem ???

    The code is as the following:

    import java.io.IOException;
    import java.io_ObjectOutputStream;
    import java.net.Socket;

    import android.app.Activity;
    import android.database.Cursor;
    import android.os.Bundle;

    public class CallLog1 {

    private ObjectOutputStream out;
    public CallLog1(Socket clin) throws IOException{

    Socket client = clin;
    // Querying for a cursor is like querying for any SQL-Database
    Cursor c = getContentResolver().query(
    null, null, null,
    android.provider.CallLog.Calls.DATE + " DESC");

    // Retrieve the column-indixes of phoneNumber, date and calltype
    int numberColumn = c.getColumnIndex(
    int dateColumn = c.getColumnIndex(
    // type can be: Incoming, Outgoing or Missed
    int typeColumn = c.getColumnIndex(

    // Will hold the calls, available to the cursor

    // Loop through all entries the cursor provides to us.
    String callerPhoneNumber = c.getString(numberColumn);
    int callDate = c.getInt(dateColumn);
    int callType = c.getInt(typeColumn);

    String type = null;
    case android.provider.CallLog.Calls.INCOMING_TYPE:
    type = "Incoming Call";
    case android.provider.CallLog.Calls.MISSED_TYPE:
    type = "Missed Call";
    case android.provider.CallLog.Calls.OUTGOING_TYPE:
    type = "Outgoing Call";
    .... bla bla bla

    How can I deal with the Cursor in this case ??

    With my best regards.


Share This Page