android - NullPointerException in startIntentSenderForResult -
i want upload image googledrive, , use example github(quickstart) .i invoke method uploadfiletodrive, locates in help-class, extends mainactivity.
void uploadfiletodrive(final bitmap bitmap) { drive.driveapi.newcontents(mainactivity.mgoogleapiclient).setresultcallback(new resultcallback<contentsresult>() { @override public void onresult(contentsresult res) { outputstream outputstream = res.getcontents().getoutputstream(); bytearrayoutputstream bitmapstream = new bytearrayoutputstream(); bitmap.compress(bitmap.compressformat.png, 100, bitmapstream); try { outputstream.write(bitmapstream.tobytearray()); } catch (ioexception e1) { clients.prt("firstexception"); } metadatachangeset metadatachangeset = new metadatachangeset.builder() .setmimetype("image/jpeg").settitle("android photo.png").build(); intentsender intentsender = drive.driveapi .newcreatefileactivitybuilder() .setinitialmetadata(metadatachangeset) .setinitialcontents(res.getcontents()) .build(mainactivity.mgoogleapiclient); try { startintentsenderforresult( //exception line intentsender, 0, null, 0, 0, 0); } catch (exception e) { e.printstacktrace(); } } }); }
but nullpointerexception:
04-22 12:22:52.548: w/system.err(2377): java.lang.nullpointerexception 04-22 12:22:52.558: w/system.err(2377): @ android.app.activity.startintentsenderforresultinner(activity.java:3499) 04-22 12:22:52.558: w/system.err(2377): @ android.app.activity.startintentsenderforresult(activity.java:3476) 04-22 12:22:52.588: w/system.err(2377): @ android.app.activity.startintentsenderforresult(activity.java:3443) 04-22 12:22:52.588: w/system.err(2377): @ com.example.mathdirectory.materials.drivehelper$2.onresult(drivehelper.java:128)
the connect googledrive correct, can image. please, help, problem?
Comments
Post a Comment