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

  • Home
  • SEARCH
  • 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 8124051
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T06:21:14+00:00 2026-06-06T06:21:14+00:00

I am uploading an image. When I run application from eclipse on my device

  • 0

I am uploading an image. When I run application from eclipse on my device it runs fine and uploads file perfectly fine. When I close app and start it from device menu and then when I try to upload image it gives me RuntimeException error. I have no idea whats going on. Help please

here is my code

public class Camera extends Activity {
ImageView ivUserImage;
Button bUpload;
Intent i;
int CameraResult = 0;
Bitmap bmp;
public String globalUID;
UserFunctions userFunctions;
String photoName;
InputStream is;
String largeImagePath;

int serverResponseCode = 0;

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.camera);

    userFunctions = new UserFunctions();
    globalUID = getIntent().getExtras().getString("globalUID");
    Toast.makeText(getApplicationContext(), globalUID, Toast.LENGTH_LONG).show();
    ivUserImage = (ImageView)findViewById(R.id.ivUserImage);
    bUpload = (Button)findViewById(R.id.bUpload);
    openCamera();
}

private void openCamera() {
    i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
    startActivityForResult(i, CameraResult);
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    super.onActivityResult(requestCode, resultCode, data);

    if(resultCode == RESULT_OK) {
        //set image taken from camera on ImageView
        Bundle extras = data.getExtras();
        bmp = (Bitmap) extras.get("data");
        ivUserImage.setImageBitmap(bmp);

        //Create new Cursor to obtain the file Path for the large image
         String[] largeFileProjection = {
                 MediaStore.Images.ImageColumns._ID,
                 MediaStore.Images.ImageColumns.DATA
         };

         String largeFileSort = MediaStore.Images.ImageColumns._ID + " DESC";
         Cursor myCursor = this.managedQuery(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, largeFileProjection, null, null, largeFileSort);

         try {
             myCursor.moveToFirst();
             //This will actually give you the file path location of the image.
             largeImagePath = myCursor.getString(myCursor.getColumnIndexOrThrow(MediaStore.Images.ImageColumns.DATA));

             File f = new File("" + largeImagePath);

             photoName = f.getName();

             bUpload.setOnClickListener(new View.OnClickListener() {   
                 public void onClick(View v) {
                     new Upload().execute(largeImagePath, globalUID, photoName);
                 }

             });

         } finally {
             myCursor.close();
         }
    }
}
public class Upload extends AsyncTask<String, Integer, String> {

    ProgressDialog dialog;

    protected void onPreExecute() {
        dialog = ProgressDialog.show(Camera.this, "", "Uploading file...", true);
    }

    @Override
    protected String doInBackground(String... arg0) {
        // TODO Auto-generated method stub
        String success = "false";
        Bitmap bitmapOrg = BitmapFactory.decodeFile(largeImagePath);
        ByteArrayOutputStream bao = new ByteArrayOutputStream();
        bitmapOrg.compress(Bitmap.CompressFormat.JPEG, 90, bao);

        byte [] ba = bao.toByteArray();
        String ba1=Base64.encodeToString(ba, 0);

        ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
        nameValuePairs.add(new BasicNameValuePair("image",ba1));
        nameValuePairs.add(new BasicNameValuePair("imageName", photoName));
        nameValuePairs.add(new BasicNameValuePair("uid", globalUID));

        try {
            HttpClient httpclient = new DefaultHttpClient();
            HttpPost httppost = new HttpPost("http://www.example.info/android/fileupload.php");
            httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
            HttpResponse response = httpclient.execute(httppost);
            HttpEntity entity = response.getEntity();
            if(response != null) {
                success = "true";
            }
            is = entity.getContent();
        } catch(Exception e) {
            Log.e("log_tag", "Error in http connection "+e.toString());
        }
        dialog.dismiss();
        return success;
    }

    protected void onProgressUpdate(Integer...progress) {

    }

    protected void onPostExecute(String f) {
        Toast.makeText(getApplicationContext(), "File uploaded", Toast.LENGTH_LONG).show();
    }

}

}

here is my logcat

06-23 14:47:50.830: E/AndroidRuntime(7069): FATAL EXCEPTION: AsyncTask #4
06-23 14:47:50.830: E/AndroidRuntime(7069): java.lang.RuntimeException: An error occured while executing doInBackground()
06-23 14:47:50.830: E/AndroidRuntime(7069):     at android.os.AsyncTask$3.done(AsyncTask.java:200)
06-23 14:47:50.830: E/AndroidRuntime(7069):     at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:274)
06-23 14:47:50.830: E/AndroidRuntime(7069):     at java.util.concurrent.FutureTask.setException(FutureTask.java:125)
06-23 14:47:50.830: E/AndroidRuntime(7069):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:308)
06-23 14:47:50.830: E/AndroidRuntime(7069):     at java.util.concurrent.FutureTask.run(FutureTask.java:138)
06-23 14:47:50.830: E/AndroidRuntime(7069):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
06-23 14:47:50.830: E/AndroidRuntime(7069):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
06-23 14:47:50.830: E/AndroidRuntime(7069):     at java.lang.Thread.run(Thread.java:1019)
06-23 14:47:50.830: E/AndroidRuntime(7069): Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
06-23 14:47:50.830: E/AndroidRuntime(7069):     at android.graphics.BitmapFactory.nativeDecodeStream(Native Method)
06-23 14:47:50.830: E/AndroidRuntime(7069):     at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:573)
06-23 14:47:50.830: E/AndroidRuntime(7069):     at android.graphics.BitmapFactory.decodeFile(BitmapFactory.java:384)
06-23 14:47:50.830: E/AndroidRuntime(7069):     at android.graphics.BitmapFactory.decodeFile(BitmapFactory.java:412)
06-23 14:47:50.830: E/AndroidRuntime(7069):     at com.zafar.login.Camera$Upload.doInBackground(Camera.java:122)
06-23 14:47:50.830: E/AndroidRuntime(7069):     at com.zafar.login.Camera$Upload.doInBackground(Camera.java:1)
06-23 14:47:50.830: E/AndroidRuntime(7069):     at android.os.AsyncTask$2.call(AsyncTask.java:185)
06-23 14:47:50.830: E/AndroidRuntime(7069):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
06-23 14:47:50.830: E/AndroidRuntime(7069):     ... 4 more
06-23 14:47:56.280: E/WindowManager(7069): Activity com.zafar.login.DashboardActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@40a67df0 that was originally added here
06-23 14:47:56.280: E/WindowManager(7069): android.view.WindowLeaked: Activity com.zafar.login.DashboardActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@40a67df0 that was originally added here
06-23 14:47:56.280: E/WindowManager(7069):  at android.view.ViewRoot.<init>(ViewRoot.java:266)
06-23 14:47:56.280: E/WindowManager(7069):  at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:174)
06-23 14:47:56.280: E/WindowManager(7069):  at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:117)
06-23 14:47:56.280: E/WindowManager(7069):  at android.view.Window$LocalWindowManager.addView(Window.java:424)
06-23 14:47:56.280: E/WindowManager(7069):  at android.app.Dialog.show(Dialog.java:241)
06-23 14:47:56.280: E/WindowManager(7069):  at android.app.ProgressDialog.show(ProgressDialog.java:107)
06-23 14:47:56.280: E/WindowManager(7069):  at android.app.ProgressDialog.show(ProgressDialog.java:90)
06-23 14:47:56.280: E/WindowManager(7069):  at com.zafar.login.Camera$Upload.onPreExecute(Camera.java:115)
06-23 14:47:56.280: E/WindowManager(7069):  at android.os.AsyncTask.execute(AsyncTask.java:391)
06-23 14:47:56.280: E/WindowManager(7069):  at com.zafar.login.Camera$1.onClick(Camera.java:100)
06-23 14:47:56.280: E/WindowManager(7069):  at android.view.View.performClick(View.java:2538)
06-23 14:47:56.280: E/WindowManager(7069):  at android.view.View$PerformClick.run(View.java:9152)
06-23 14:47:56.280: E/WindowManager(7069):  at android.os.Handler.handleCallback(Handler.java:587)
06-23 14:47:56.280: E/WindowManager(7069):  at android.os.Handler.dispatchMessage(Handler.java:92)
06-23 14:47:56.280: E/WindowManager(7069):  at android.os.Looper.loop(Looper.java:130)
06-23 14:47:56.280: E/WindowManager(7069):  at android.app.ActivityThread.main(ActivityThread.java:3691)
06-23 14:47:56.280: E/WindowManager(7069):  at java.lang.reflect.Method.invokeNative(Native Method)
06-23 14:47:56.280: E/WindowManager(7069):  at java.lang.reflect.Method.invoke(Method.java:507)
06-23 14:47:56.280: E/WindowManager(7069):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907)
06-23 14:47:56.280: E/WindowManager(7069):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:665)
06-23 14:47:56.280: E/WindowManager(7069):  at dalvik.system.NativeStart.main(Native Method)
  • 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-06T06:21:15+00:00Added an answer on June 6, 2026 at 6:21 am

    Solution

    First of all with the help of @DheereshSingh and @duffy356 comments. I found it solution on this link.

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

Sidebar

Related Questions

So i'm uploading any image file via my great upload form and it uploads
i doing app for uploading image to php server from android and the php
I am uploading image to server using base64 its working fine if image is
I have developed an image uploading application that uses Flash to load an image,
While I am uploading the mobile and application number in multipart from-data from mobile
I recently implemented a jQuery / iframe solution to file uploading and have run
Instead of uploading image one by one, how do i achieve to upload all
My user is uploading an image of any size XX x YY. I want
I am uploading in image via a form and I want to, in addition
I have an image uploading script in which i use the following setup to

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.