android - How to sync my app with photos -


i build custom gallery photos only. taking photos sdcard class:

public class photos { public static final string photo_bucket_name =     environment.getexternalstoragestate().tostring() + "/dcim/camera"; public static final int photo_bucket_id = getbucketid(photo_bucket_name);  public static int getbucketid(string path) {     return path.tolowercase().hashcode(); }  public static list<string> getphotos(context context) {     final string[] projection = {mediastore.images.media.data};     final string selection = mediastore.images.media.bucket_id;     cursor c = context.getcontentresolver().query(images.media.external_content_uri, projection, selection, null, null);     list<string> result = new arraylist<string>(c.getcount());     if (c.movetofirst()) {         int datacolumn = c.getcolumnindexorthrow(mediastore.images.media.data);         {             string data = c.getstring(datacolumn);             result.add(data);         } while (c.movetonext());     }     c.close();     return result; } 

and set adapter gallery:

public class imageadapter extends baseadapter {     int galitembg;     private context mcontext;     private list<string> photolist;      public imageadapter(context c) {         mcontext = c;         photolist = photos.getphotos(c);         typedarray typarray = obtainstyledattributes(r.styleable.gallerytheme);         galitembg = typarray.getresourceid(r.styleable.gallerytheme_android_galleryitembackground, 0);         typarray.recycle();     }      @override     public int getcount() {         return photolist.size();     }      @override     public object getitem(int position) {         return position;     }       @override     public long getitemid(int position) {         return position;     }      @override     public view getview(int position, view convertview, viewgroup parent) {         imageview = new imageview(mcontext);          bitmap bm = bitmapfactory.decodefile(photolist.get(position));         i.setimagebitmap(bm);         i.setlayoutparams(new gallery.layoutparams(80,70));         i.setscaletype(imageview.scaletype.fit_xy);         i.setbackgroundresource(galitembg);          return i;     } } 

} there nothing special. when run app, works. after launch camera , taking photos, in time app running in background. when app, need see new photos. how it?

tried: update adapter in onresume method this:

gallery g;  public void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.main);     g = (gallery) findviewbyid(r.id.gallery);     g.setadapter(new imageadapter(this)); }  @override public void onresume() {     g.setadapter(new imageadapter(this)); } 

app crashing. may wrong?

logcat:

02-09 08:12:33.719: error/androidruntime(276): uncaught handler: thread main exiting due uncaught exception 02-09 08:12:34.129: error/androidruntime(276): java.lang.runtimeexception: unable resume activity {ru.home.tabexample/ru.home.tabexample.tabact}: java.lang.runtimeexception: unable resume activity {ru.home.tabexample/ru.home.tabexample.firsttab}: android.app.supernotcalledexception: activity {ru.home.tabexample/ru.home.tabexample.firsttab} did not call through super.onresume() 02-09 08:12:34.129: error/androidruntime(276):     @ android.app.activitythread.performresumeactivity(activitythread.java:2950) 02-09 08:12:34.129: error/androidruntime(276):     @ android.app.activitythread.handleresumeactivity(activitythread.java:2965) 02-09 08:12:34.129: error/androidruntime(276):     @ android.app.activitythread.handlelaunchactivity(activitythread.java:2516) 02-09 08:12:34.129: error/androidruntime(276):     @ android.app.activitythread.access$2200(activitythread.java:119) 02-09 08:12:34.129: error/androidruntime(276):     @ android.app.activitythread$h.handlemessage(activitythread.java:1863) 02-09 08:12:34.129: error/androidruntime(276):     @ android.os.handler.dispatchmessage(handler.java:99) 02-09 08:12:34.129: error/androidruntime(276):     @ android.os.looper.loop(looper.java:123) 02-09 08:12:34.129: error/androidruntime(276):     @ android.app.activitythread.main(activitythread.java:4363) 02-09 08:12:34.129: error/androidruntime(276):     @ java.lang.reflect.method.invokenative(native method) 02-09 08:12:34.129: error/androidruntime(276):     @ java.lang.reflect.method.invoke(method.java:521) 02-09 08:12:34.129: error/androidruntime(276):     @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:860) 02-09 08:12:34.129: error/androidruntime(276):     @ com.android.internal.os.zygoteinit.main(zygoteinit.java:618) 02-09 08:12:34.129: error/androidruntime(276):     @ dalvik.system.nativestart.main(native method) 02-09 08:12:34.129: error/androidruntime(276): caused by: java.lang.runtimeexception: unable resume activity {ru.home.tabexample/ru.home.tabexample.firsttab}: android.app.supernotcalledexception: activity {ru.home.tabexample/ru.home.tabexample.firsttab} did not call through super.onresume() 02-09 08:12:34.129: error/androidruntime(276):     @ android.app.activitythread.performresumeactivity(activitythread.java:2950) 02-09 08:12:34.129: error/androidruntime(276):     @ android.app.localactivitymanager.movetostate(localactivitymanager.java:170) 02-09 08:12:34.129: error/androidruntime(276):     @ android.app.localactivitymanager.dispatchresume(localactivitymanager.java:518) 02-09 08:12:34.129: error/androidruntime(276):     @ android.app.activitygroup.onresume(activitygroup.java:58) 02-09 08:12:34.129: error/androidruntime(276):     @ android.app.instrumentation.callactivityonresume(instrumentation.java:1149) 02-09 08:12:34.129: error/androidruntime(276):     @ android.app.activity.performresume(activity.java:3763) 02-09 08:12:34.129: error/androidruntime(276):     @ android.app.activitythread.performresumeactivity(activitythread.java:2937) 02-09 08:12:34.129: error/androidruntime(276):     ... 12 more 02-09 08:12:34.129: error/androidruntime(276): caused by: android.app.supernotcalledexception: activity {ru.home.tabexample/ru.home.tabexample.firsttab} did not call through super.onresume() 02-09 08:12:34.129: error/androidruntime(276):     @ android.app.activity.performresume(activity.java:3765) 02-09 08:12:34.129: error/androidruntime(276):     @ android.app.activitythread.performresumeactivity(activitythread.java:2937) 02-09 08:12:34.129: error/androidruntime(276):     ... 18 more 

you have call super.onresume in onresume method.

you can see in message of exception: android.app.supernotcalledexception: activity {ru.home.tabexample/ru.home.tabexample.firsttab} did not call through super.onresume()

the activity base class uses onresume methods reinitialise stuff. if implement in class leave out super.onresume() call initializations in base class can not made.


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -