I am facing issues while saving an image browsed from my SD card inside my 
mobile, and then generate a url from it.

I tried the code from the below link on cloudinary website.

https://github.com/cloudinary/cloudinary_android

On line 9 commented, it throws a Null Pointer Exception. I dont understand 
why? The imageStream variable is not null.

Here is the code:-

mbtnPickAndSave = (Button) findViewById(R.id.btnPickAndSave);
mbtnPickAndSave.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {

        Intent photopickerIntent=new Intent(Intent.ACTION_PICK);
        photopickerIntent.setType("image/*");
        startActivityForResult(photopickerIntent, 2);

    }
});

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

    InputStream imageStream=null;
    if (requestCode==2)
    {
        Uri imageUri = data.getData();
        try {
              imageStream = getContentResolver().openInputStream(imageUri);
        }
        catch(Exception ex)
        {
            System.out.println(ex.getMessage());
        }

        try {
            Cloudinary cloudinary;
            Button mbtnPickAndSave;
            Map config;
            config = new HashMap();
            config.put("cloud_name", "softronic");
            config.put("api_key", "416823682763972");
            config.put("api_secret", "Ymm8QXBDCR8HQF6oXwu8f0cdsFs");
            cloudinary = new Cloudinary(config);
            cloudinary.uploader().upload(imageStream, Cloudinary.emptyMap()); 
// Line 9
            cloudinary.url().generate("diwan.jpg");            
        }
        catch(Exception ex)
        {
            System.out.println(ex.getMessage());
        }

    }

}


If someone, has worked on some other image saving service like ImgUr and knows 
the code as how to save it on remote location, please refer that to me.



Regards,

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to