2012-11-27 4 views
-2

안드로이드 VoiceMailContract 코드 표시되지 않을 : 항상 나에게 0 음성 메일을 보여 그리고 나 또한 구글 음성 메일 미리안드로이드 4.0 이상 VoiceMailContract 적절한 결과를

+1

순수 코드 서면 요청에서 작동한다 (그리고 최소한의 시간을 가지고 있었다 스택 오버플로에 오프 주제입니다 전체 문장 쓰기). – assylias

답변

0

유용한 코드 감사를 통합하려는

public void voiceMail(Context ctx) { 
    if (Build.VERSION.SDK_INT >= 14) { 
     try { 
      final String selection = VoicemailContract.Voicemails.IS_READ + "=0"; 
      final String sortOrder = VoicemailContract.Voicemails.DATE + " DESC"; 
      String uri = VoicemailContract.Voicemails.CONTENT_URI + "?" 
        + VoicemailContract.PARAM_KEY_SOURCE_PACKAGE + "=" 
        + getPackageName(); 
      Cursor cursor = ctx.getContentResolver().query(Uri.parse(uri), null, 
        selection, null, sortOrder); 
      TextView tv = (TextView)findViewById(R.id.textView1); 
      tv.setText("You have "+cursor.getCount()+" voice mail"); 
      cursor.close(); 
     } catch (Exception e) { 
      e.printStackTrace(); 
     } 
    } 
} 

나 :

Cursor cursor = null; 
    try { 
     cursor = mContentResolver.query(mBaseUri, FULL_PROJECTION, 
       filter != null ? filter.getWhereClause() : null, 
       null, getSortBy(sortColumn, sortOrder)); 
     while (cursor.moveToNext()) { 
      // A performance optimisation is possible here. 
      // The helper method extracts the column indices once every time it is called, 
      // whilst 
      // we could extract them all up front (without the benefit of the re-use of the 
      // helper 
      // method code). 
      // At the moment I'm pretty sure the benefits outweigh the costs, so leaving as-is. 
     } 
     Log.v(TAG,"Unread Voicemails:"+cursot.getCount()); 
     return results; 
    } finally { 
     cursor.close(); 
    } 

난 단지 콘텐츠 URI를 변경해야하지만 여전히 두 간접적으로 동일하지만 또한이 작품은 나를 위해, 그리고 당신은 또한 다시 수 안드로이드 SDK의 "VoicemailProviderDemo"의 FER 샘플 프로젝트

는 참고 :이 코드는 안드로이드 4.0 이상

관련 문제