Go Back   Android Forums > Android Development > Application Development
Application Development Dev lounge for our application developers.

Get excited for the Samsung Galaxy S5! Find everything you need and discuss it in our Galaxy S5 Forum!

test: Reply
LinkBack Thread Tools
Old May 4th, 2009, 03:43 PM   #1 (permalink)
New Member
Thread Author (OP)
Join Date: Mar 2009
Posts: 9
Carrier: Not Provided

Thanks: 0
Thanked 0 Times in 0 Posts
Default how to deal with classes in android? help please

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.

kwty is offline  
Reply With Quote
sponsored links

Go Back   Android Forums > Android Development > Application Development
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

All times are GMT -5. The time now is 04:03 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.