getting callog

  • Thread starter Thread starter Mustafa Rabie
  • Start date Start date
M

Mustafa Rabie

hi all,
does anyone has a sample application the uses the opennetcf.phone.callog
class?
i wrote a function that returns reads the calllog and returns a list of the
CallLogEntry(s) that has missed call types, here's the function's code:

private OpenNETCF.Phone.CallLogEntry[] GetAllMissed()
{
OpenNETCF.Phone.CallLog cCallLog = new CallLog();

OpenNETCF.Phone.CallLogEntry[] aRet;

try

{

int n = cCallLog.Seek(OpenNETCF.Phone.CallLogSeek.End,0);

for (int i=0; i < n; i++)

{

if (cCallLog.CallType == OpenNETCF.Phone.CallType.Missed)

{

aRet = cCallLog;

}

}

}

catch (Exception err)

{

string s = err.Message;

}

return aRet;

}



I know that i have to initialize the array b4 using it, but i donno how
since there's no constructor for CallLogEntry class i.e. i can't do the
following

OpenNETCF.Phone.CallLogEntry myEntry = new CallLogEntry();

so how can i initialize the array? since i want to have a dynamic array that
has a length of the number of entried returned,

i do the following with string arrays n it works fine but it doesn't work
with this

string[] myStringList = myString.Split('\\'); // this works gr8

Your help is really appreciated

thanks

mustafa rabie
 
also how can i declare and initialize the array that will hold the data this
function returns
 
Since you want a resizable collection, one easy way is to use an ArrayList.
Create an ArrayList then as you return each record add it to the ArrayList.
Then at the end you can create a fixed length array from the contents of the
ArrayList of a specific type - CallLogEntry in this case. You also might
find it more efficient to use a for each loop e.g.

private OpenNETCF.Phone.CallLogEntry[] GetAllMissed()
{
OpenNETCF.Phone.CallLog cCallLog = new CallLog();
ArrayList alMissed = new ArrayList();

foreach(CallLogEntry entry in cCallLog)
{
if(entry.CallType == OpenNETCF.Phone.CallType.Missed)
{
alMissed.Add(entry);
}
}

return
(OpenNETCF.Phone.CallLogEntry[])alMissed.ToArray(typeof(OpenNETCF.Phone.CallLogEntry));
}

Peter
 
thanks peter i was just posting a message that i found the solution! :)
but thanks for your fast reply that's what's makes a gr8 MVP....
Peter Foot said:
Since you want a resizable collection, one easy way is to use an
ArrayList. Create an ArrayList then as you return each record add it to
the ArrayList. Then at the end you can create a fixed length array from
the contents of the ArrayList of a specific type - CallLogEntry in this
case. You also might find it more efficient to use a for each loop e.g.

private OpenNETCF.Phone.CallLogEntry[] GetAllMissed()
{
OpenNETCF.Phone.CallLog cCallLog = new CallLog();
ArrayList alMissed = new ArrayList();

foreach(CallLogEntry entry in cCallLog)
{
if(entry.CallType == OpenNETCF.Phone.CallType.Missed)
{
alMissed.Add(entry);
}
}

return
(OpenNETCF.Phone.CallLogEntry[])alMissed.ToArray(typeof(OpenNETCF.Phone.CallLogEntry));
}

Peter

--
Peter Foot
Windows Embedded MVP
www.inthehand.com | www.opennetcf.org

Mustafa Rabie said:
hi all,
does anyone has a sample application the uses the opennetcf.phone.callog
class?
i wrote a function that returns reads the calllog and returns a list of
the CallLogEntry(s) that has missed call types, here's the function's
code:

private OpenNETCF.Phone.CallLogEntry[] GetAllMissed()
{
OpenNETCF.Phone.CallLog cCallLog = new CallLog();

OpenNETCF.Phone.CallLogEntry[] aRet;

try

{

int n = cCallLog.Seek(OpenNETCF.Phone.CallLogSeek.End,0);

for (int i=0; i < n; i++)

{

if (cCallLog.CallType == OpenNETCF.Phone.CallType.Missed)

{

aRet = cCallLog;

}

}

}

catch (Exception err)

{

string s = err.Message;

}

return aRet;

}



I know that i have to initialize the array b4 using it, but i donno how
since there's no constructor for CallLogEntry class i.e. i can't do the
following

OpenNETCF.Phone.CallLogEntry myEntry = new CallLogEntry();

so how can i initialize the array? since i want to have a dynamic array
that has a length of the number of entried returned,

i do the following with string arrays n it works fine but it doesn't work
with this

string[] myStringList = myString.Split('\\'); // this works gr8

Your help is really appreciated

thanks

mustafa rabie

 
Back
Top