Thursday 15 January 2015

android - Can't access photos taken within app on Google Glass -



android - Can't access photos taken within app on Google Glass -

i'm on roll here beingness confused google glass development! app taking photos using built-in photographic camera functionality , sample code on gdk site (https://developers.google.com/glass/develop/gdk/camera). when take photo, looks image beingness taken, when seek upload imgur server (using api), filenotfound exception. when seek using android studio's file explorer, can't seem find images in filepath should in. seems file not beingness created, or i'm accessing wrong path somehow. doing wrong?

code using camera:

public void startrecog(){ intent intent = new intent(mediastore.action_image_capture); startactivityforresult(intent, capture_image_activity_request_code); } @override protected void onactivityresult(int requestcode, int resultcode, intent data) { log.i(tag,"got onactivity"); log.i(tag,"request code: " + requestcode + ", result code: " + resultcode + ", wants: " + result_ok); if (requestcode == capture_image_activity_request_code && resultcode == result_ok) { log.i(tag,"got within if"); string picturepath = data.getstringextra(intents.extra_thumbnail_file_path); // string picturepath = data.getstringextra(intents.extra_picture_file_path); log.i(tag,"the real path: " + picturepath); processpicturewhenready(picturepath); } super.onactivityresult(requestcode, resultcode, data); } private void processpicturewhenready(final string picturepath) { final file picturefile = new file(picturepath); if (picturefile.exists()) { // image ready; process it. log.i(tag,"got in image processing"); new imguruploadtask(uri.parse(picturepath), this).execute(); } else { // file not exist yet. before starting file observer, // can update ui allow user know application // waiting image (for example, displaying thumbnail // image , progress indicator). final file parentdirectory = picturefile.getparentfile(); fileobserver observer = new fileobserver(parentdirectory.getpath(), fileobserver.close_write | fileobserver.moved_to) { // protect against additional pending events after close_write // or moved_to handled. private boolean isfilewritten; @override public void onevent(int event, string path) { if (!isfilewritten) { // safety, create sure file created in // directory 1 we're expecting. file affectedfile = new file(parentdirectory, path); isfilewritten = affectedfile.equals(picturefile); if (isfilewritten) { stopwatching(); // file ready, recursively phone call // processpicturewhenready 1 time again (on ui thread). runonuithread(new runnable() { @override public void run() { processpicturewhenready(picturepath); } }); } } } }; observer.startwatching(); } }

the errors getting:

11-01 14:34:43.281 10449-10449/com.example.cerveau.recognizeplaces i/recogplaces﹕ got onactivity 11-01 14:34:43.281 10449-10449/com.example.cerveau.recognizeplaces i/recogplaces﹕ request code: 100, result code: -1, wants: -1 11-01 14:34:43.281 10449-10449/com.example.cerveau.recognizeplaces i/recogplaces﹕ got within if 11-01 14:34:43.281 10449-10449/com.example.cerveau.recognizeplaces i/recogplaces﹕ real path: /storage/emulated/0/storage/emulated/0/thumbnail_cache/t_thumb_20141101_143439_397.jpg 11-01 14:34:43.281 10449-10449/com.example.cerveau.recognizeplaces i/recogplaces﹕ got in image processing 11-01 14:34:43.288 10449-10704/com.example.cerveau.recognizeplaces e/imguruploadtask﹕ not open inputstream java.io.filenotfoundexception: no content provider: /storage/emulated/0/thumbnail_cache/t_thumb_20141101_143439_397.jpg @ android.content.contentresolver.opentypedassetfiledescriptor(contentresolver.java:1049) @ android.content.contentresolver.openassetfiledescriptor(contentresolver.java:904) @ android.content.contentresolver.openinputstream(contentresolver.java:629) @ com.example.cerveau.recognizeplaces.imguruploadtask.doinbackground(imguruploadtask.java:32) @ com.example.cerveau.recognizeplaces.imguruploadtask.doinbackground(imguruploadtask.java:16) @ android.os.asynctask$2.call(asynctask.java:302) @ java.util.concurrent.futuretask.run(futuretask.java:237) @ android.os.asynctask$serialexecutor$1.run(asynctask.java:240) @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1112) @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:587) @ java.lang.thread.run(thread.java:841)

and yes, think have right permissions set in androidmanifest...

<uses-permission android:name="android.permission.camera" /> <uses-permission android:name="com.google.android.glass.permission.development" /> <uses-permission android:name="android.permission.write_external_storage"/> <uses-permission android:name="android.permission.internet" />

thanks guys! maintain butting head problems every step of way developing glass , it's frustrating me no end. appreciate help!

new imguruploadtask(uri.parse(picturepath)

this problem. can't utilize uri.parse on storage path (like "/storage/emulated/0/thumbnail_cache...") because not qualified.

create uri this:

uri.fromfile(picturefile)

this output valid uri origin "file://".

android android-camera google-glass imgur

No comments:

Post a Comment