I try to capture a image by intenting camera and set that as a profile picture in my app.
Camera captures images but picture nothing is set in profile, still blank and want to upload that picture to my server.
While reading the picture by DataInputStream it says, "The method readLine() from the type DataInputStream is deprecated".
Help me to resolve this problem.
Here is my code is:
    public void settings(){
                AlertDialog.Builder alertDialog2 = new AlertDialog.Builder(SignUp.this);
                alertDialog2.setTitle("");
                alertDialog2.setMessage("Please select an image..");
                alertDialog2.setIcon(R.drawable.act_camera);
                alertDialog2.setPositiveButton("CAMERA.",
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int which) {
                                condition="from_camera";
                                pd = ProgressDialog.show(SignUp.this, "", "Please wait...", true);
                                Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);            
                                startActivityForResult(cameraIntent, CAM_REQUREST);     
                            }
                        });
                        alertDialog2.setNegativeButton("GALLERY.",
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int which) {
                                condition="from_gallery";
                                pd = ProgressDialog.show(SignUp.this, "", "Please wait...", true);
                                Intent i = new Intent(Intent.ACTION_PICK,android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
                                startActivityForResult(i, RESULT_LOAD_IMAGE);
                            }
                        });
                alertDialog2.show();
                                } 
            @JavascriptInterface
        public void showCustomAlert() {
            // TODO Auto-generated method stub
             Context context = getApplicationContext();
                // Create layout inflator object to inflate toast.xml file
                LayoutInflater inflater = getLayoutInflater();
                // Call toast.xml file for toast layout 
                View toastRoot = inflater.inflate(R.layout.toast, null);
                Toast toast = new Toast(context);
                // Set layout to toast 
                toast.setView(toastRoot);
                toast.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL,
                        0, 0);
                toast.setDuration(Toast.LENGTH_LONG);
                toast.show();
        }
        protected void onActivityResult(int requestCode, int resultCode, Intent data)
     {  
     super.onActivityResult(requestCode, resultCode, data);  
           if (requestCode == CAM_REQUREST) 
           {  
               bitmap_profile_image = (Bitmap) data.getExtras().get("data");  
               imagepath =  ImageWrite(bitmap_profile_image); 
               pd.dismiss();
           } 
         else if (requestCode == RESULT_LOAD_IMAGE && resultCode == RESULT_OK && null != data) 
           {
               Uri selectedImage = data.getData();
               String[] filePathColumn = { MediaStore.Images.Media.DATA };
               Cursor cursor = getContentResolver().query(selectedImage,
                       filePathColumn, null, null, null);
               cursor.moveToFirst();
               int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
               String picturePath = cursor.getString(columnIndex);
               Bitmap thumbnail = (BitmapFactory.decodeFile(picturePath));
               cursor.close();
               john.setImageBitmap(thumbnail); 
               System.out.println("Step--------->1");
               pd1 = ProgressDialog.show(SignUp.this, "", "Please wait...", true);
               System.out.println("Step--------->1");
               imagepath =  ImageWrite(thumbnail);
               pd1.dismiss();
               pd.dismiss();
               Log.w("path of image from gallery......*******.....", picturePath+"");
           } 
         else{
         }    
           Imageuploading();  
          }
        public String ImageWrite(Bitmap bitmap1)
        {
            //pd = ProgressDialog.show(context,null, "Please wait...",true);
             String extStorageDirectory = Environment.getExternalStorageDirectory().toString();
                OutputStream outStream = null;
                File file = new File(extStorageDirectory, "slectimage.PNG");
                try 
                {
                    outStream = new FileOutputStream(file);
                    bitmap1.compress(Bitmap.CompressFormat.PNG, 100, outStream);
                    outStream.flush();
                    outStream.close();
                    pd.dismiss();
                } 
                catch (FileNotFoundException e) 
                {
                    e.printStackTrace();
                    pd.dismiss();
                } catch (IOException e) 
                {
                    e.printStackTrace();
                    pd.dismiss();
                }
                String imageInSD = "/sdcard/slectimage.PNG";
            pd.dismiss();
                return imageInSD;
        }
        protected void Imageuploading() {
            // TODO Auto-generated method stub
            pd1 = ProgressDialog.show(this,null, "Please wait...",true);
             try{
                    Log.e("SANGUUU", "dfdf");
                    HttpURLConnection connection = null;
                    DataOutputStream outputStream = null;
                    String pathToOurFile = (String) imagepath; 
                    System.out.println("patho our file"+pathToOurFile);
                    //String urlServer = "http://demo.cogzideltemplates.com/client/snapchat-clone/index.php/user/image_upload";
                    String urlServer = "http://demo.cogzidel.com/sedio/mobile/image_upload";
                    String lineEnd = "\r\n";
                    String twoHyphens = "--";
                    String boundary =  "*****";
                    int bytesRead, bytesAvailable, bufferSize;
                    byte[] buffer;
                    int maxBufferSize = 1*1024*1024;
                    FileInputStream fileInputStream = new FileInputStream(new File(pathToOurFile));
                    URL url = new URL(urlServer);
                    connection = (HttpURLConnection) url.openConnection();
                    // Allow Inputs & Outputs
                    connection.setDoInput(true);
                    connection.setDoOutput(true);
                    connection.setUseCaches(false);
                    // Enable POST method
                    connection.setRequestMethod("POST");
                    connection.setRequestProperty("Connection", "Keep-Alive");
                    connection.setRequestProperty("Content-Type", "multipart/form-data;boundary="+boundary);
                    outputStream = new DataOutputStream( connection.getOutputStream() );
                    outputStream.writeBytes(twoHyphens + boundary + lineEnd);
                    outputStream.writeBytes("Content-Disposition: form-data; name=\"uploadedfile\";filename=\"" + pathToOurFile +"\"" + lineEnd);
                    outputStream.writeBytes(lineEnd);
                    bytesAvailable = fileInputStream.available();
                    bufferSize = Math.min(bytesAvailable, maxBufferSize);
                    buffer = new byte[bufferSize];
                    // Read file
                    bytesRead = fileInputStream.read(buffer, 0, bufferSize);
                    while (bytesRead > 0)
                    {
                        System.out.println("test");
                    outputStream.write(buffer, 0, bufferSize);
                    bytesAvailable = fileInputStream.available();
                    bufferSize = Math.min(bytesAvailable, maxBufferSize);
                    bytesRead = fileInputStream.read(buffer, 0, bufferSize);
                    }
                    outputStream.writeBytes(lineEnd);
                    outputStream.writeBytes(twoHyphens + boundary + twoHyphens + lineEnd);
                    connection.getResponseCode();
                    String serverResponseMessage = connection.getResponseMessage();
                    URL serverResponseMessage1 = connection.getURL();
                    System.out.println("url value"+serverResponseMessage1);
                    connection.getResponseMessage();
                //  Toast.makeText(getApplicationContext(),  serverResponseMessage, Toast.LENGTH_LONG).show();
                    System.out.println("image"+serverResponseMessage);
                    int len=connection.getContentLength();
                    System.out.println("Length of url--->1"+len);                
                    fileInputStream.close();
                    outputStream.flush();
                    outputStream.close();
                    DataInputStream inputStream1 = null;
                    inputStream1 = new DataInputStream (connection.getInputStream());
                    String str="";
                    String Str1_imageurl="";
                    while ((  str = inputStream1.readLine()) != null)  // here getting deprecated error
                    {
                       Log.e("Debug","Server Response "+str);
                        Str1_imageurl = str;
                        Log.e("Debug","Server Response String imageurl"+str);
                    }
                    inputStream1.close();
                    System.out.println("image url"+Str1_imageurl);
            //      Toast.makeText(getApplicationContext(),  Str1_imageurl, Toast.LENGTH_LONG).show();
                    pd1.dismiss();
                       stry=Str1_imageurl.trim();
                         }
                         catch(Exception e){
                                e.printStackTrace();
                         }
        }
     //create helping method cropCapturedImage(Uri picUri)
     public void cropCapturedImage(Uri picUri){
      //call the standard crop action intent
      Intent cropIntent = new Intent("com.android.camera.action.CROP");
      //indicate image type and Uri of image
      cropIntent.setDataAndType(picUri, "image/*");
      //set crop properties
      cropIntent.putExtra("crop", "true");
      //indicate aspect of desired crop
      cropIntent.putExtra("aspectX", 1);
      cropIntent.putExtra("aspectY", 1);
      //indicate output X and Y
      cropIntent.putExtra("outputX", 256);
      cropIntent.putExtra("outputY", 256);
      //retrieve data on return
      cropIntent.putExtra("return-data", true);
      //start the activity - we handle returning in onActivityResult
      startActivityForResult(cropIntent, 2);
     }
 
     
    