android.os.DeadObjectException error while creating a mp3player -
while creating simple mp3player stop button , when run code , android.os.deadobjectexception error pops out , unable find out reason behind this. please reply if can figure out. in advance. following code , latter 1 logcat view.
package com.songs.playit; import java.io.file; import java.io.filenamefilter; import java.io.ioexception; import java.util.arraylist; import java.util.list; import android.app.listactivity; import android.media.mediaplayer; import android.os.bundle; import android.os.environment; import android.util.log; import android.view.view; import android.view.view.onclicklistener; import android.widget.arrayadapter; import android.widget.button; import android.widget.listview; public class mainactivity extends listactivity { private final static string sdpath = new string(environment.getexternalstoragedirectory().getabsolutepath()); private list<string> songs = new arraylist<string>(); mediaplayer mp =new mediaplayer(); @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.fragment_main); updateplaylist(); button stopplay = (button) findviewbyid(r.id.stopbtn); stopplay.setonclicklistener(new onclicklistener(){ public void onclick(view v){ mp.stop(); } }); } private void updateplaylist() { // todo auto-generated method stub file home = new file(sdpath); if(home.listfiles(new mp3filter()).length>0){ for(file file: home.listfiles( new mp3filter())){ songs.add (file.getname()); } arrayadapter<string> songlist= new arrayadapter<string>(this , r.layout.songs_item); setlistadapter(songlist); } } protected void onlistitemclick(listview list , view v , int position , long id){ try{ mp.reset(); mp.setdatasource(sdpath + songs.get(position)); mp.prepare(); mp.start(); } catch(ioexception e){ log.v(getstring(r.string.app_name), e.getmessage()); } } @override protected void ondestroy() { super.ondestroy(); } } class mp3filter implements filenamefilter { @override public boolean accept(file dir, string filename) { // todo auto-generated method stub { return (filename.endswith(".mp3")); } } }
here logcat view
08-18 12:37:12.810: e/javabinder(664): *** uncaught remote exception! (exceptions not yet supported across processes.) 08-18 12:37:12.810: e/javabinder(664): java.lang.runtimeexception: android.os.deadobjectexception 08-18 12:37:12.810: e/javabinder(664): @ android.os.parcel.writeexception(parcel.java:1366) 08-18 12:37:12.810: e/javabinder(664): @ android.os.binder.exectransact(binder.java:410) 08-18 12:37:12.810: e/javabinder(664): @ dalvik.system.nativestart.run(native method) 08-18 12:37:12.810: e/javabinder(664): caused by: android.os.deadobjectexception 08-18 12:37:12.810: e/javabinder(664): @ android.os.binderproxy.transact(native method) 08-18 12:37:12.810: e/javabinder(664): @ android.content.iintentreceiver$stub$proxy.performreceive(iintentreceiver.java:124) 08-18 12:37:12.810: e/javabinder(664): @ android.app.activitythread$applicationthread.scheduleregisteredreceiver(activitythread.java:816) 08-18 12:37:12.810: e/javabinder(664): @ android.app.applicationthreadnative.ontransact(applicationthreadnative.java:394) 08-18 12:37:12.810: e/javabinder(664): @ android.os.binder.exectransact(binder.java:404) 08-18 12:37:12.810: e/javabinder(664): ... 1 more
Comments
Post a Comment