0

I m trying to upload new pdf file to google drive in android application. but it throws null exception. it only upload image format. so please give any suggestion how to upload pdf file.

protected void onActivityResult(final int requestCode, final int resultCode, 
                                final Intent data) {
    switch (requestCode) {
        case REQUEST_CODE_CAPTURE_IMAGE:
            if (resultCode == Activity.RESULT_OK) {
                Uri uri = data.getData();
                try {
                    mBitmapToSave = BitmapFactory.decodeStream(
                            getContentResolver().openInputStream(uri));
                    Toast.makeText(getApplicationContext(), filenameSP, 3000).show();
                } catch (FileNotFoundException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                mBitmapToSave = BitmapFactory.decodeStream(
                        getContentResolver().openInputStream(uri));

Here I am passing my pdf file path its throw nullPointerException.

Cheryl Simon
  • 46,552
  • 15
  • 93
  • 82
sikan
  • 76
  • 9
  • You may look at this link [http://stackoverflow.com/questions/16964218/android-launch-a-google-drive-application-from-another-application-not-uploaded][1] [1]: http://stackoverflow.com/questions/16964218/android-launch-a-google-drive-application-from-another-application-not-uploaded – Orcun Sevsay Mar 30 '15 at 14:57
  • Same thing i have done but its not working... – sikan Mar 30 '15 at 15:09
  • No stack trace and corresponding line numbered code? – pinoyyid Mar 30 '15 at 18:14

1 Answers1

0

You should check the following links

https://developers.google.com/drive/web/manage-uploads

https://code.google.com/p/google-drive-sdk-samples/

mehmetunlu
  • 239
  • 2
  • 5