java - There is no error but still can't change phone contact image -


i'm quit scared application. i'm developing application changes contact photo image-view. doesn't generate error not change contact image. have doubt, if it's onactivityresult() method. please correct me on that. here code of onactivityresult() method.

    if (resultcode == activity.result_ok) {          switch (requestcode) {         case image_pick:                 this.imagefromgallery(resultcode, data);             break;         case image_capture:             this.imagefromcamera(resultcode, data);             break;          case pick_photo:                 if(resultcode == result_ok){                       // getting uri of picked photo                     uri updateimageview = data.getdata();                      inputstream imagestream = null;                     try {                         // getting inputstream of selected image                         imagestream = getcontentresolver().openinputstream(updateimageview);                     } catch (filenotfoundexception e) {                         e.printstacktrace();                     }                      // creating bitmap of selected image inputstream                     image = bitmapfactory.decodestream(imagestream);                      // getting reference imageview                    // imagebutton ibphoto = (imagebutton) findviewbyid(r.id.photo);                      // setting bitmap imagebutton                     photo.setimagebitmap(image);                 }                  break;         default:             break;         }     } } 

also here onclick() code.

 save.setonclicklistener(new view.onclicklistener()      {          @override         public void onclick(view arg0)         {              arraylist<contentprovideroperation> ops =                     new arraylist<contentprovideroperation>();               int position=getintent().getextras().getint("bmp");             int po=ops.size();             bytearrayoutputstream stream = new bytearrayoutputstream();                if(image!=null)               { // if image selected                   image.compress(bitmap.compressformat.png , 100, stream);                   //   bytearrayoutputstream stream = new bytearrayoutputstream();                   image.compress(bitmap.compressformat.png , 75, stream);                    ops.add(contentprovideroperation.newupdate(contactscontract.data.content_uri)                              .withvalue(contactscontract.data.raw_contact_id, position) // here position _id i'm inserting image                              .withvalue(contactscontract.data.is_super_primary, 1)                              .withvalue(contactscontract.data.mimetype,contactscontract.commondatakinds.photo.content_item_type)                              .withvalue(contactscontract.commondatakinds.photo.photo,stream.tobytearray())                              .build());                        try {                            stream.flush();                            } catch (ioexception e) {                             // todo auto-generated catch block                             e.printstacktrace();                           }                      }                 else               {                   log.d("image null", "true");               }               try{                    // executing insert operations single database transaction                   getcontentresolver().applybatch(contactscontract.authority,ops);                   toast.maketext(getbasecontext(), "contact image change successfully", toast.length_short).show();               }         catch (remoteexception e) {                   e.printstacktrace();                }catch (operationapplicationexception e) {                   e.printstacktrace();               }                          }       }); 


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -