try to do that in asyc task.
private class asynUpload extends AsyncTask<String, Void, Integer> {
protected Integer doInBackground(String... params) {
try {
runOnUiThread(new Runnable() {
public void run() {
pd = ProgressDialog.show(FaceActivity.this, "Please Wait", "Loading...", true, false);
}
});
bm = BitmapFactory.decodeFile(picturePath);
bos = new ByteArrayOutputStream();
bm.compress(Bitmap.CompressFormat.JPEG, 40 , bos);
bitmapdata = bos.toByteArray();
ParseFile file = new ParseFile("pic.jpg", bitmapdata);
file.saveInBackground();
ParseObject po = new ParseObject("Images");
po.put("Images", file);
po.saveInBackground();
ImageView imageView = (ImageView) findViewById(R.id.targetimage);
imageView.setImageBitmap(BitmapFactory.decodeFile(picturePath,options));
} catch (Exception e) {
return 0;
}
return 1;
}
protected void onPostExecute(Integer result) {
try {
runOnUiThread(new Runnable() {
public void run() {
pd.dismiss();
}
});
} catch (Exception e) {}
super.onPostExecute(result);
}
}