2012-04-18 12 views
1

私はthisコードを使用してカレンダーから予定を取得していました。カレンダーからイベントを取得する際の問題

request time failed: java.net.SocketException: Address family not supported by protocol 

私は、この行にそのコードのクラッシュに気づいたデバッグ:

Cursor eventCursor = contentResolver 
        .query(builder.build(), new String[] 
        { "title", "begin", "end", "allDay" }, 
          "Calendars._id=" + 1, null, 
          "startDay ASC, startMinute ASC"); 

System.out.println("eventCursor count=" + eventCursor.getCount()); 

任意のアイデアが参考になります

は、しかし、私はエラーこのようなを得ました。ありがとう。

答えて

1

OSバージョンでエラーが発生しました。 SDK-7を使用している可能性があります。代わりにこのコードを試してください。

Uri.Builder builder; 
     if (android.os.Build.VERSION.SDK_INT <= 7) 
     { 
     // the old way 
     builder = Uri.parse("content://calendar/instances/when").buildUpon(); 
     } else 
     { 
     // the new way 
     builder = Uri 
     .parse("content://com.android.calendar/instances/when").buildUpon(); 
     } 

これは正常に動作するはずです。

+1

ありがとう、それは働いた:) – asish

関連する問題