[android-developers] Re: How to retrieve outgoing number

2010-05-16 Thread mike

hi Galbayar,

What exactly did u mean by use _id, i don't know the id what i know is
the mobile number. that method delete all the log's for that number
expect for the current call. that's the issue

i'm using this method in here



class StateListener extends PhoneStateListener {
@Override
public void onCallStateChanged(int state, String 
incomingNumber) {
// TODO Auto-generated method stub
// super.onCallStateChanged(state, incomingNumber);
switch (state) {
case TelephonyManager.CALL_STATE_RINGING:
phonenbr = incomingNumber;

break;
case TelephonyManager.CALL_STATE_IDLE:

 clearCallLog(phonenbr);
break;
case TelephonyManager.CALL_STATE_OFFHOOK:
phonenbr = incomingNumber;

break;
}
}
}


public void clearCallLog(String mobileNumber) {
Cursor c = context.getContentResolver().query(
CallLog.Calls.CONTENT_URI, null,
Calls.NUMBER + =' + mobileNumber + ', null,
Calls.DATE +  DESC);
context.getContentResolver().cancelSync(Calls.CONTENT_URI);
// startManagingCursor(c);
String number = null;
String date;
int dateColumn = c.getColumnIndex(Calls.DATE);
int numberColumn = c.getColumnIndex(Calls.NUMBER);
if (c != null) {
if (c.moveToFirst()) {
// do {
// Get the field values
date = c.getString(dateColumn);
number = c.getString(numberColumn);
Log.d(NUmber, number);
Log.d(Date, date);
// alert(number, number);
// } while (c.moveToNext());
}
int i = 
context.getContentResolver().delete(Calls.CONTENT_URI,
Calls.NUMBER + =' + number + ', 
null);
Log.d(DELETE ID, Integer.toString(i));
//telManager.listen(new StateListener(), LISTEN_NONE);

System.exit(0);
// finish();
// alert(Delete, Integer.toString(i));
}
}

what i think is in TelephonyManager.CALL_STATE_IDLE state the current
call entry is not there. can it be the reason, but logically that too
can't happen. because the call is already over so the entry should be
there

so can you help me

regards,
Randika

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: How to retrieve outgoing number

2010-05-01 Thread mike
hi Galbayar,

found a issue about the method you gave me to find out the Outgoing
Number. the issue is assume that i have dialed 12345 first. the method
returns the number accurately. but if i  dialed 456789 after that
again the method returns the number as 12345.

and if i dialed another number for the third time then the method will
return 456789 as the number.

to have a clear view below is my code.

this is a very urgent case your quick response is really appriciated.

//*** Code ***


package com.sabretch.mobility.coloreyed.callerview1.listener;

import java.text.BreakIterator;

import com.sabretch.mobility.coloreyed.callerview1.AnimationView;
import com.sabretch.mobility.coloreyed.callerview1.outgoing.OutGoing;
import android.content.BroadcastReceiver;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.database.Cursor;
import android.provider.BaseColumns;
import android.provider.CallLog;
import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager;
import android.util.Log;

public class CallListener extends BroadcastReceiver {
private Context context;
// Intent inten = null;
String phonenbr;

@Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
this.context = context;
TelephonyManager telManager = (TelephonyManager) context
.getSystemService(Context.TELEPHONY_SERVICE);
telManager.listen(new StateListener(),
PhoneStateListener.LISTEN_CALL_STATE);

}

class StateListener extends PhoneStateListener {
@Override
public void onCallStateChanged(int state, String 
incomingNumber) {
// TODO Auto-generated method stub
// super.onCallStateChanged(state, incomingNumber);
switch (state) {
case TelephonyManager.CALL_STATE_RINGING:
Log.d(DEBUG, RINGING);
break;
case TelephonyManager.CALL_STATE_IDLE:
//BroadcastReceiver.this.clearAbortBroadcast();
//context.unregisterReceiver(this.);
System.exit(0);
break;
case TelephonyManager.CALL_STATE_OFFHOOK:
phonenbr = getLastCallLogEntry(context);
break;
}
}
}

private String getLastCallLogEntry(Context context) {
String[] projection = new String[] { BaseColumns._ID,
CallLog.Calls.NUMBER, CallLog.Calls.TYPE };
ContentResolver resolver = context.getContentResolver();
Cursor cur = resolver.query(CallLog.Calls.CONTENT_URI, 
projection,
null, null, CallLog.Calls.DEFAULT_SORT_ORDER);
int numberColumn = cur.getColumnIndex(CallLog.Calls.NUMBER);
int typeColumn = cur.getColumnIndex(CallLog.Calls.TYPE);

if (!cur.moveToNext()) {
cur.close();
return ;
}
String number = cur.getString(numberColumn);
String type = cur.getString(typeColumn);
String dir = null;
try {
int dircode = Integer.parseInt(type);
switch (dircode) {
case CallLog.Calls.OUTGOING_TYPE:
dir = OUTGOING;
break;

case CallLog.Calls.INCOMING_TYPE:
dir = INCOMING;
break;

case CallLog.Calls.MISSED_TYPE:
dir = MISSED;
break;
}
} catch (NumberFormatException ex) {
}
if (dir == null)
dir = Unknown, code:  + type;
cur.close();
return number;

}

}

//

regards,
Mike


-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: How to retrieve outgoing number

2010-04-28 Thread mike
hi Galbayar D,

thanks for your help.it works fine and it has solve my issue.
appreciate what you have done.

have another issue when a call is receiving how to delete the call log
entry. i have tried it but it always delete the other entries not the
current call entry.
this is my method

public void clearCallLog() {
Cursor c = getContentResolver().query(Calls.CONTENT_URI, null,
Calls.NUMBER + =' + mobileNumber + ', null,
Calls.DATE +  DESC);
getContentResolver().cancelSync(Calls.CONTENT_URI);
startManagingCursor(c);
String number = null;
String date;
int dateColumn = c.getColumnIndex(Calls.DATE);
int numberColumn = c.getColumnIndex(Calls.NUMBER);
if (c != null) {
if (c.moveToFirst()) {
// do {
// Get the field values
date = c.getString(dateColumn);
number = c.getString(numberColumn);
Log.d(NUmber, number);
Log.d(Date, date);
alert(number, number);
// } while (c.moveToNext());
}
int i =getContentResolver().delete(Calls.CONTENT_URI,
Calls.NUMBER + =' + number + ', 
null);
alert(Delete, Integer.toString(i));
}
}

regards,
Randika

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: How to retrieve outgoing number

2010-04-28 Thread mike
hi Galbayar D,

thanks for your help.it works fine and it has solve my issue.
appreciate what you have done.

have another issue when a call is receiving how to delete the call log
entry. i have tried it but it always delete the other entries not the
current call entry.
this is my method

public void clearCallLog() {
Cursor c = getContentResolver().query(Calls.CONTENT_URI, null,
Calls.NUMBER + =' + mobileNumber + ', null,
Calls.DATE +  DESC);
getContentResolver().cancelSync(Calls.CONTENT_URI);
startManagingCursor(c);
String number = null;
String date;
int dateColumn = c.getColumnIndex(Calls.DATE);
int numberColumn = c.getColumnIndex(Calls.NUMBER);
if (c != null) {
if (c.moveToFirst()) {
// do {
// Get the field values
date = c.getString(dateColumn);
number = c.getString(numberColumn);
Log.d(NUmber, number);
Log.d(Date, date);
alert(number, number);
// } while (c.moveToNext());
}
int i =getContentResolver().delete(Calls.CONTENT_URI,
Calls.NUMBER + =' + number + ', 
null);
alert(Delete, Integer.toString(i));
}
}

regards,
Randika

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: How to retrieve outgoing number

2010-04-28 Thread mike
hi Galbayar D,

thanks for your help.it works fine and it has solve my issue.
appreciate what you have done.

have another issue when a call is receiving how to delete the call log
entry. i have tried it but it always delete the other entries not the
current call entry.
this is my method

public void clearCallLog() {
Cursor c = getContentResolver().query(Calls.CONTENT_URI, null,
Calls.NUMBER + =' + mobileNumber + ', null,
Calls.DATE +  DESC);
getContentResolver().cancelSync(Calls.CONTENT_URI);
startManagingCursor(c);
String number = null;
String date;
int dateColumn = c.getColumnIndex(Calls.DATE);
int numberColumn = c.getColumnIndex(Calls.NUMBER);
if (c != null) {
if (c.moveToFirst()) {
// do {
// Get the field values
date = c.getString(dateColumn);
number = c.getString(numberColumn);
Log.d(NUmber, number);
Log.d(Date, date);
alert(number, number);
// } while (c.moveToNext());
}
int i =getContentResolver().delete(Calls.CONTENT_URI,
Calls.NUMBER + =' + number + ', 
null);
alert(Delete, Integer.toString(i));
}
}

regards,
Randika

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Re: How to retrieve outgoing number

2010-04-28 Thread Galbayar D
HI Make

try to use _id= column in where section.

On Wed, Apr 28, 2010 at 7:38 PM, mike hasitharand...@gmail.com wrote:

 hi Galbayar D,

 thanks for your help.it works fine and it has solve my issue.
 appreciate what you have done.

 have another issue when a call is receiving how to delete the call log
 entry. i have tried it but it always delete the other entries not the
 current call entry.
 this is my method

public void clearCallLog() {
Cursor c = getContentResolver().query(Calls.CONTENT_URI,
 null,
Calls.NUMBER + =' + mobileNumber + ',
 null,
Calls.DATE +  DESC);
getContentResolver().cancelSync(Calls.CONTENT_URI);
startManagingCursor(c);
String number = null;
String date;
int dateColumn = c.getColumnIndex(Calls.DATE);
int numberColumn = c.getColumnIndex(Calls.NUMBER);
if (c != null) {
if (c.moveToFirst()) {
// do {
// Get the field values
date = c.getString(dateColumn);
number = c.getString(numberColumn);
Log.d(NUmber, number);
Log.d(Date, date);
alert(number, number);
// } while (c.moveToNext());
}
int i
 =getContentResolver().delete(Calls.CONTENT_URI,
Calls.NUMBER + =' + number + ',
 null);
alert(Delete, Integer.toString(i));
 }
}

 regards,
 Randika

 --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en




-- 
==
Tel:976-70151145
Fax:976-70151146
Mobile: 976-88115679
Web: http://www.usi.mn
==

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en