Pregunta

I have made an Android app that I am trying to port over to a blackberry 10 device. Currently, all of the functions of the app work except for one, where I try and get information about recent calls from the phone. This works fine on android, but does not seem to work on the blackberry 10 simulator I am using. Here is my code for the section:

final TextView time = (TextView) findViewById(R.id.AddNewEditTextTime);
final TextView date = (TextView) findViewById(R.id.AddNewEditTextDate);
final TextView number = (TextView) findViewById(R.id.AddNewEditTextNumber);

// fields to select.
String[] strFields = { android.provider.CallLog.Calls.NUMBER,
        android.provider.CallLog.Calls.TYPE,
        android.provider.CallLog.Calls.CACHED_NAME,
        android.provider.CallLog.Calls.CACHED_NUMBER_TYPE,
        android.provider.CallLog.Calls.DATE};

// only incoming.
String strSelection = android.provider.CallLog.Calls.TYPE + " = "
        + android.provider.CallLog.Calls.INCOMING_TYPE;

// most recent first
String strOrder = android.provider.CallLog.Calls.DATE + " DESC";

// get a cursor.
Cursor mCallCursor = getContentResolver().query(
    android.provider.CallLog.Calls.CONTENT_URI, // content provider
                                                        // URI
    strFields, // project (fields to get)
    strSelection, // selection
    null, // selection args
    strOrder // sortorder.
    );

if (mCallCursor.moveToFirst()) {
    String a = mCallCursor.getString(mCallCursor
            .getColumnIndex("date"));
    String b = mCallCursor.getString(mCallCursor
            .getColumnIndex("number"));
    mCallCursor.close();

    SimpleDateFormat dateF = new SimpleDateFormat("dd-MMM-yyyy");
    SimpleDateFormat timeF = new SimpleDateFormat("HH:mm");
    String dateString = dateF.format(new Date(Long
            .parseLong(a)));
    String timeString = timeF.format(new Date(Long
            .parseLong(a)));
    time.setText(timeString);
    date.setText(dateString);
    number.setText(b);
}

The if(mCallCursor.moveToFirst()) statement is never entered on the blackberry 10 device, but works fine on Android. Is there something I'm missing / doing wrong, or is there no way to use the android.provider functions like this on a blackberry 10 device?

¿Fue útil?

Solución

Apparently accessing call log is not yet supported

This is not supported, the Android API is not hooked up to retreive this data.

Edit: Usually when there's an equivalent native API, the corresponding API in Android will be supported. The Android API almost always uses the native equivalent for its implementation. AFAIK there isn't a native call logs API.

By bbenninger, at support forums.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top