받기 :나는 같은 것을 사용하여 연락처의 사진을 얻을 수 있습니다 알고 RawContact 사진
public InputStream getContactPhotoInputStream() throws IOException {
Uri uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_URI, String.valueOf(mContactId));
InputStream is = ContactsContract.Contacts.openContactPhotoInputStream(contentResolver, uri);
return is;
}
을하지만 지금은 모든 RawContact의 사진 (하나를 가지고있는 하나)에 액세스해야합니다. 그러나 나는 할 수 없다. ContactsContract.RawContacts.DisplayPhoto 설명서에서 사진은 파일로 저장되고 썸네일은 테이블에 Blob
으로 저장됩니다. 간단한 쿼리로 축소판 사진을 데이터베이스에 가져올 수 있으며 Blob
을 검색 할 수 있습니다. 그러나 이제는 원본 크기의 사진이 필요하며 얻을 수있는 방법을 찾을 수 없습니다. Google에서 안드로이드 설명서에 대한 정보를 찾을 수 없습니다.
나는 사진 파일을 얻기 위해이 방법을 시도했지만 성공하지 못했다.
public InputStream getRawContactPhotoInputStream() throws IOException
{
Uri rawContactPhotoUri = Uri.withAppendedPath(
ContentUris.withAppendedId(RawContacts.CONTENT_URI, Long.parseLong(mRawContactId)),
RawContacts.DisplayPhoto.CONTENT_DIRECTORY);
AssetFileDescriptor fd = contentResolver.openAssetFileDescriptor(rawContactPhotoUri, "rw");
InputStream is = fd.createInputStream();
fd.close();
return is;
}
내가 로그 캣에이 얻을 :
02-18 23:44:27.195: D/PhotoRestlet(8984): Representation1 size < 1
02-18 23:44:27.207: W/System.err(8984): 2014-02-18 23:44:27 10.17.1.54 - - 8080 GET /contact/photo/6 - 200 - 0 35 http://10.17.1.72:8080 Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36 -
02-18 23:44:27.226: W/System.err(8984): Unable to read the entity
02-18 23:44:27.226: W/System.err(8984): java.io.IOException: read failed: EBADF (Bad file number)
02-18 23:44:27.226: W/System.err(8984): at java.nio.FileChannelImpl.readImpl(FileChannelImpl.java:315)
02-18 23:44:27.226: W/System.err(8984): at java.nio.FileChannelImpl.read(FileChannelImpl.java:287)
02-18 23:44:27.226: W/System.err(8984): at org.restlet.engine.io.ReadableChunkingChannel.read(ReadableChunkingChannel.java:137)
02-18 23:44:27.226: W/System.err(8984): at org.restlet.engine.io.Buffer.fill(Buffer.java:395)
02-18 23:44:27.226: W/System.err(8984): at org.restlet.engine.connector.OutboundWay.onFill(OutboundWay.java:388)
02-18 23:44:27.226: W/System.err(8984): at org.restlet.engine.io.Buffer.process(Buffer.java:601)
02-18 23:44:27.226: W/System.err(8984): at org.restlet.engine.connector.Way.processIoBuffer(Way.java:503)
02-18 23:44:27.226: W/System.err(8984): at org.restlet.engine.connector.OutboundWay.processIoBuffer(OutboundWay.java:463)
02-18 23:44:27.226: W/System.err(8984): at org.restlet.engine.connector.Way.onSelected(Way.java:456)
02-18 23:44:27.230: W/System.err(8984): at org.restlet.util.SelectionRegistration.onSelected(SelectionRegistration.java:325)
02-18 23:44:27.230: W/System.err(8984): at org.restlet.engine.connector.Connection.onSelected(Connection.java:617)
02-18 23:44:27.230: W/System.err(8984): at org.restlet.util.SelectionRegistration.onSelected(SelectionRegistration.java:325)
02-18 23:44:27.230: W/System.err(8984): at org.restlet.engine.connector.ConnectionController.onSelected(ConnectionController.java:219)
02-18 23:44:27.230: W/System.err(8984): at org.restlet.engine.connector.ServerConnectionController.onSelected(ServerConnectionController.java:99)
02-18 23:44:27.230: W/System.err(8984): at org.restlet.engine.connector.ConnectionController.selectKeys(ConnectionController.java:308)
02-18 23:44:27.230: W/System.err(8984): at org.restlet.engine.connector.ConnectionController.doRun(ConnectionController.java:171)
02-18 23:44:27.230: W/System.err(8984): at org.restlet.engine.connector.Controller.run(Controller.java:159)
02-18 23:44:27.230: W/System.err(8984): at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
02-18 23:44:27.230: W/System.err(8984): at java.util.concurrent.FutureTask.run(FutureTask.java:237)
02-18 23:44:27.230: W/System.err(8984): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
02-18 23:44:27.230: W/System.err(8984): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
02-18 23:44:27.230: W/System.err(8984): at java.lang.Thread.run(Thread.java:841)
02-18 23:44:27.230: W/System.err(8984): Caused by: libcore.io.ErrnoException: read failed: EBADF (Bad file number)
02-18 23:44:27.230: W/System.err(8984): at libcore.io.Posix.readBytes(Native Method)
02-18 23:44:27.230: W/System.err(8984): at libcore.io.Posix.read(Posix.java:123)
02-18 23:44:27.230: W/System.err(8984): at libcore.io.BlockGuardOs.read(BlockGuardOs.java:144)
02-18 23:44:27.230: W/System.err(8984): at java.nio.FileChannelImpl.readImpl(FileChannelImpl.java:303)
02-18 23:44:27.230: W/System.err(8984): ... 21 more
02-18 23:44:27.250: D/PhotoRestlet(8984): Representation1 size < 1
02-18 23:44:27.250: W/System.err(8984): 2014-02-18 23:44:27 10.17.1.54 - - 8080 GET /contact/photo/6 - 1001 - 0 17 http://10.17.1.72:8080 Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36 -
02-18 23:44:27.269: D/PhotoRestlet(8984): Representation1 size < 1
02-18 23:44:27.273: W/System.err(8984): 2014-02-18 23:44:27 10.17.1.54 - - 8080 GET /contact/photo/6 - 1001 - 0 19 http://10.17.1.72:8080 Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36 -
02-18 23:44:27.308: D/skia(1925): --- SkImageDecoder::Factory returned null
02-18 23:44:27.308: D/skia(1925): --- SkImageDecoder::Factory returned null
02-18 23:44:27.316: D/skia(1925): --- SkImageDecoder::Factory returned null