Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9199961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:39:32+00:00 2026-06-17T22:39:32+00:00

i am trying to upload selected image to dropbox from gallery.I am being stuck

  • 0

i am trying to upload selected image to dropbox from gallery.I am being stuck up from days because i am getting unable to resume Runtime Exception

My onActivityResult() is

 if(requestCode == PIC_UPLOAD) {

    System.out.println("Reahced 1");

    Uri selectedImage = data.getData();
    String[] filePathColumn ={MediaStore.Images.Media.DATA};

    Cursor cursor = getContentResolver().query(selectedImage,
                     filePathColumn, null, null, null); cursor.moveToFirst();

    System.out.println("Reahced 2");

    int columnIndex = cursor.getColumnIndex(filePathColumn[0]); 
   String filePath = cursor.getString(columnIndex); 
   cursor.close();


    Uri imageUri=data.getData();
   List<NameValuePair> params = new ArrayList<NameValuePair>(1); 
   params.add(new  BasicNameValuePair("image", imageUri.getPath()));
    System.out.println("Reahced 3");


    /* String outPath = imageUri.toString(); File outFile = new
       File(outPath); FileInputStream fis = new FileInputStream(outFile);
       mDBApi.putFileOverwriteRequest("/Pic1", fis, outFile.length(),null);
    */

   Uri photoUri = data.getData(); 
   String[] proj = {MediaStore.Images.Media.DATA };
   Cursor actualimagecursor = managedQuery(photoUri, proj,null, null, null);
   int actual_image_column_index =
   actualimagecursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
   actualimagecursor.moveToFirst();
   String img_path =actualimagecursor.getString(actual_image_column_index);

   System.out.println("Image location: " + img_path);

   System.out.println("Reached 1"); 

   uploadDropbox(img_path);
}

And uploadDropbox body is:

    private void uploadDropbox(String URL) {
    // TODO Auto-generated method stub
        AppKeyPair appKeys = new AppKeyPair(APP_KEY, APP_SECRET);
        AndroidAuthSession session = new AndroidAuthSession(appKeys, ACCESS_TYPE);
        mDBApi = new DropboxAPI<AndroidAuthSession>(session);

        System.out.println(URL);

        System.out.println("Reahced 4");

        mDBApi.getSession().startAuthentication(MyCamActivity.this);

        System.out.println("Reahced 5");

//      AccessTokenPair access = getStoredKeys();
//      mDBApi.getSession().setAccessTokenPair(access);

        FileInputStream inputStream = null;
        try {
            File file = new File(URL.toString());
            inputStream = new FileInputStream(file);
            com.dropbox.client2.DropboxAPI.Entry newEntry = mDBApi.putFile("/testing.txt", inputStream, file.length(), null, null);
            Log.i("DbExampleLog", "The uploaded file's rev is: " + newEntry.rev);
        } catch (DropboxUnlinkedException e) {
            // User has unlinked, ask them to link again here.
            Log.e("DbExampleLog", "User has unlinked.");
        } catch (DropboxException e) {
            Log.e("DbExampleLog", "Something went wrong while uploading.");
        } catch (FileNotFoundException e) {
            Log.e("DbExampleLog", "File not found.");
        } finally {
            if (inputStream != null) {
                try {
                    inputStream.close();
                } catch (IOException e) {}
            }
        }
    }

onResume method body:

protected void onResume() {
    super.onResume();

    if (mDBApi.getSession().authenticationSuccessful()) {
      try {
        // MANDATORY call to complete auth.
        // Sets the access token on the session
        mDBApi.getSession().finishAuthentication();

        AccessTokenPair tokens = mDBApi.getSession().getAccessTokenPair();

        // Provide your own storeKeys to persist the access token pair
        // A typical way to store tokens is using SharedPreferences
        storeKeys(tokens.key, tokens.secret);
        } catch (IllegalStateException e) {
          Log.i("DbAuthLog", "Error authenticating", e);
        }
    }

}

private AccessTokenPair getStoredKeys() {
// TODO Auto-generated method stub

return  mDBApi.getSession().getAccessTokenPair();

}

private void storeKeys(String key, String secret) {
// TODO Auto-generated method stub

    // Save the access key for later
    SharedPreferences prefs = getSharedPreferences(ACCOUNT_PREFS_NAME, 0);
    Editor edit = prefs.edit();
    edit.putString(ACCESS_KEY_NAME, key);
    edit.putString(ACCESS_SECRET_NAME, secret);
    edit.commit();
}

AndroidManifest.xml

    <activity
  android:name="com.dropbox.client2.android.AuthActivity"
  android:launchMode="singleTask"
  android:configChanges="orientation|keyboard">
  <intent-filter>
    <!-- Change this to be db- followed by your app key -->
    <data android:scheme="db-MyKey" />
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.BROWSABLE"/>
    <category android:name="android.intent.category.DEFAULT" />
  </intent-filter>
</activity>


    <activity
        android:name=".MyCamActivity"
        android:label="@string/app_name" 
        android:screenOrientation="nosensor" android:configChanges="keyboardHidden|orientation"
        android:uiOptions="splitActionBarWhenNarrow"
        android:clearTaskOnLaunch="true"
        >

Error**:

01-23 14:58:00.855: D/dalvikvm(4238): GC_FOR_ALLOC freed 104K, 2% free 12729K/12935K, paused 16ms
01-23 14:58:00.894: I/System.out(4238): Its not null
01-23 14:58:00.901: D/AndroidRuntime(4238): Shutting down VM
01-23 14:58:00.901: W/dalvikvm(4238): threadid=1: thread exiting with uncaught exception (group=0x40a511f8)
01-23 14:58:00.901: E/AndroidRuntime(4238): FATAL EXCEPTION: main
01-23 14:58:00.901: E/AndroidRuntime(4238): java.lang.RuntimeException: Unable to resume activity {cam.pack/cam.pack.MyCamActivity}: java.lang.NullPointerException
01-23 14:58:00.901: E/AndroidRuntime(4238):     at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2444)
01-23 14:58:00.901: E/AndroidRuntime(4238):     at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2472)
01-23 14:58:00.901: E/AndroidRuntime(4238):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1986)
01-23 14:58:00.901: E/AndroidRuntime(4238):     at android.app.ActivityThread.access$600(ActivityThread.java:123)
01-23 14:58:00.901: E/AndroidRuntime(4238):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
01-23 14:58:00.901: E/AndroidRuntime(4238):     at android.os.Handler.dispatchMessage(Handler.java:99)
01-23 14:58:00.901: E/AndroidRuntime(4238):     at android.os.Looper.loop(Looper.java:137)
01-23 14:58:00.901: E/AndroidRuntime(4238):     at android.app.ActivityThread.main(ActivityThread.java:4424)
01-23 14:58:00.901: E/AndroidRuntime(4238):     at java.lang.reflect.Method.invokeNative(Native Method)
01-23 14:58:00.901: E/AndroidRuntime(4238):     at java.lang.reflect.Method.invoke(Method.java:511)
01-23 14:58:00.901: E/AndroidRuntime(4238):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
01-23 14:58:00.901: E/AndroidRuntime(4238):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
01-23 14:58:00.901: E/AndroidRuntime(4238):     at dalvik.system.NativeStart.main(Native Method)
01-23 14:58:00.901: E/AndroidRuntime(4238): Caused by: java.lang.NullPointerException
01-23 14:58:00.901: E/AndroidRuntime(4238):     at cam.pack.MyCamActivity.onResume(MyCamActivity.java:571)
01-23 14:58:00.901: E/AndroidRuntime(4238):     at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1154)
01-23 14:58:00.901: E/AndroidRuntime(4238):     at android.app.Activity.performResume(Activity.java:4539)
01-23 14:58:00.901: E/AndroidRuntime(4238):     at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2434)
01-23 14:58:00.901: E/AndroidRuntime(4238):     ... 12 more
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T22:39:33+00:00Added an answer on June 17, 2026 at 10:39 pm

    I have made a mistake, i have put dropbox session in my own defined function uploadDropbox(), and thats a an error causes NullPointerException, because if i print mDBApi so its NULL. Its not been intialized. We have to put these lines in onCreate() and now its working, images are uploading in CameraUploads folder in Dropbox.

    Thanks for comments.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to upload an image file from an android device to my drupal
I'm trying to write flash applet where user can upload image from their hard
I'm trying to upload a rails app to dotcloud. I'm getting this error: PG::Error
I am trying to get my head around and using the selected image in
I am trying to upload camera images from iPhone to my web server but
I am trying to get the file that the user has selected from the
I am using swfupload plugin. When I am trying to upload an image I
I am trying to create a simple screen where the file selected for upload
I'm trying to create thumbnails (288x288) of selected photos from iPad photo library. I
I am trying to extract EXIF data from a image(jpeg) which has been dragged

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.