android - ParseQuery to return file -


i trying imagefile, user's profile image. have store image users table enter image description here app

@override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_main);      mtoolbar = (toolbar) findviewbyid(r.id.toolbar);      setsupportactionbar(mtoolbar);      navigationitemslist = new arraylist<draweritem>();     additemstonavigationlist();       mrecyclerview = (recyclerview) findviewbyid(r.id.recyclerview);     mrecyclerview.sethasfixedsize(true);       parseuser username = parseuser.getcurrentuser();     header_name = username.getusername();     header_email = username.getemail();     madapter = new com.charity.dogood.dogood.adapters.navdraweradapter(navigationitemslist, this, header_name, header_email, header_image);     mrecyclerview.setadapter(madapter);       //parse image , details of logged in user     // locate class table named "imageupload" in parse.com     parsequery<parseobject> query =  new parsequery("user");     log.d("mainactivity", "after query 1");      parseuser currentuser = parseuser.getcurrentuser();      log.d("mainactivity", "after query 2");             query.whereequalto("username", "bro");     log.d("mainactivity", "after query 3");     log.d("mainactivity", currentuser.getusername());     // string usernam = (string)currentuser;      if(currentuser != null){         log.d("mainactivity", "came current user check statement");     query.getinbackground("bro", new getcallback<parseobject>() {          @override         public void done(parseobject object, parseexception e) {               if (e == null) {                 parsefile fileobject = (parsefile) object.getparsefile("imageprofile");                   fileobject.getdatainbackground(new getdatacallback() {                      @override                     public void done(byte[] bytes, parseexception e) {                         if (e == null) {                             toast.maketext(mainactivity.this, "welcome back", toast.length_long).show();                             bitmap bmp = bitmapfactory.decodebytearray(bytes, 0, bytes.length);                              // header_image image = (imageview) fin                         } else {                             alertdialog.builder builder = new alertdialog.builder(mainactivity.this);                             builder.setmessage(e.getmessage());                             builder.settitle("sorry");                             builder.setpositivebutton("ok", new dialoginterface.onclicklistener() {                                 @override                                 public void onclick(dialoginterface dialoginterface, int i) {                                     dialoginterface.dismiss();                                 }                             });                             alertdialog dialog = builder.create();                             dialog.show();                         }                      }                 });             } else {                 alertdialog.builder builder = new alertdialog.builder(mainactivity.this);                 builder.setmessage(e.getmessage());                 builder.settitle("sorry");                 builder.setpositivebutton("ok", new dialoginterface.onclicklistener() {                     @override                     public void onclick(dialoginterface dialoginterface, int i) {                         dialoginterface.dismiss();                     }                 });                 alertdialog dialog = builder.create();                 dialog.show();              }          }     });         log.d("mainactivity", "after query 4"); } 

i able username , email in drawer not image,

enter image description here check put in here, check object null-ivty.

if (e == null) { 

i getting error message

enter image description here

i believe getting 'no results found query' because query parsequery("user") not search users class.

try changing

parsequery<parseobject> query =  new parsequery("user") 

to

parsequery<parseuser> query = parseuser.getquery(); 

this how users should queried according to: https://parse.com/docs/android/guide#users-querying

however still not think need query when interested in current user:

    if(currentuser != null){         log.d("mainactivity", "came current user check statement");     currentuser.fetchifneededinbackground(new getcallback<parseobject>() {          @override         public void done(parseobject object, parseexception e) {               if (e == null) {                 parsefile fileobject = (parsefile) object.getparsefile("imageprofile");                   fileobject.getdatainbackground(new getdatacallback() {                      @override                     public void done(byte[] bytes, parseexception e) {                         if (e == null) {                             toast.maketext(mainactivity.this, "welcome back", toast.length_long).show();                             bitmap bmp = bitmapfactory.decodebytearray(bytes, 0, bytes.length);                              // header_image image = (imageview) fin                         } else {                             alertdialog.builder builder = new alertdialog.builder(mainactivity.this);                             builder.setmessage(e.getmessage());                             builder.settitle("sorry");                             builder.setpositivebutton("ok", new dialoginterface.onclicklistener() {                                 @override                                 public void onclick(dialoginterface dialoginterface, int i) {                                     dialoginterface.dismiss();                                 }                             });                             alertdialog dialog = builder.create();                             dialog.show();                         }                      }                 });             } else {                 alertdialog.builder builder = new alertdialog.builder(mainactivity.this);                 builder.setmessage(e.getmessage());                 builder.settitle("sorry");                 builder.setpositivebutton("ok", new dialoginterface.onclicklistener() {                     @override                     public void onclick(dialoginterface dialoginterface, int i) {                         dialoginterface.dismiss();                     }                 });                 alertdialog dialog = builder.create();                 dialog.show();              }          }     }); 

Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -