从启动画面移动到播放列表时,应用程序崩溃

时间:2014-11-27 17:51:41

标签: java android eclipse

我正在尝试构建一个视频播放器,我设法获得徽标屏幕但是当我的应用程序从徽标移动到播放列表时...它崩溃了

package com.example.droid;
import java.io.File;
import java.io.FilenameFilter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import android.net.Uri;
import android.content.ContentResolver;
import android.database.Cursor;
import android.widget.ListView;``
import android.os.Bundle;
import android.app.ListActivity;


class VidFilter implements FilenameFilter {
    public boolean accept(File dir, String name){
        return (name.endsWith(".3gp"));
    }   
}

      public class playlist extends ListActivity {
          private long id;
          private String title;  
          private ArrayList<playlist> videoList;
          private ListView videoView;


          @Override
          protected void onCreate(Bundle savedInstanceState){
             super.onCreate(savedInstanceState);
             setContentView(R.layout.videoplaylist);
             videoView = (ListView)findViewById(R.id.myList);
             videoList = new ArrayList<playlist>();
             getvideoList();

             VideoAdapter VAdap = new VideoAdapter(this, videoList);
             videoView.setAdapter(VAdap);


             Collections.sort(videoList, new Comparator<playlist>(){
                 public int compare(playlist a, playlist b){
                     return a.getTTL().compareTo(b.getTTL());

          }
          });

          }

          public void getvideoList(){
              //retrieve video info
              ContentResolver videoResolver = getContentResolver();
              Uri videoUri = android.provider.MediaStore.Video.Media.INTERNAL_CONTENT_URI;
              Cursor videoCursor = videoResolver.query(videoUri, null, null, null, null);

              if (videoCursor!=null && videoCursor.moveToFirst()){

                  int titleColumn = videoCursor.getColumnIndex
                          (android.provider.MediaStore.Video.Media.TITLE);

                  int idColumn = videoCursor.getColumnIndex
                          (android.provider.MediaStore.Video.Media._ID);
                  //add video to list
                  do {
                      long thisId = videoCursor.getLong(idColumn);
                      String thisTitle = videoCursor.getString(titleColumn);
                      videoList.add(new playlist(thisId, thisTitle));
                  }
                  while (videoCursor.moveToNext());

              }

          }

      public playlist(long videoID, String videoTitle) {
        id= videoID;  
        title=videoTitle;}

        public long getID(){return id;}
        public String getTTL(){return title;}

        public static playlist get(int position) {
            // TODO Auto-generated method stub
            return null;
        }

      }

11-27 17:42:58.409:I / Process(19075):发送信号。 PID:19075 SIG:9 11-27 17:43:04.429:E / MoreInfoHPW_View(19485):父视图不是TextView 11-27 17:43:04.519:D / dalvikvm(19485):GC_FOR_ALLOC释放211K,12%释放16218K / 18404K,暂停13ms,总计13ms 11-27 17:43:04.519:D / Activity(19485):#3 setTransGradationModeColor为false 11-27 17:43:04.579:I / Adreno-EGL(19485):: EGL 1.4 QUALCOMM build :() 11-27 17:43:04.579:I / Adreno-EGL(19485):OpenGL ES着色器编译器版本:E031.24.02.11 11-27 17:43:04.579:I / Adreno-EGL(19485):建立日期:09/04/14星期四 11-27 17:43:04.579:I / Adreno-EGL(19485):当地分行:LA.3.6.1_20140904_070_patches 11-27 17:43:04.579:I / Adreno-EGL(19485):远程分支: 11-27 17:43:04.579:I / Adreno-EGL(19485):本地补丁: 11-27 17:43:04.579:I / Adreno-EGL(19485):重建分支: 11-27 17:43:04.599:I / HWUI(19485):EGLImpl-HWUI受保护的EGL上下文已创建 11-27 17:43:04.599:I / qdutils(19485):PartialUpdate状态:已启用 11-27 17:43:04.599:I / qdutils(19485):左对齐:8 11-27 17:43:04.599:I / qdutils(19485):宽度对齐:8 11-27 17:43:04.599:I / qdutils(19485):Top Align:1 11-27 17:43:04.599:I / qdutils(19485):高度对齐:1 11-27 17:43:04.599:I / qdutils(19485):最小ROI宽度:1 11-27 17:43:04.599:I / qdutils(19485):最低投资回报率高度:2 11-27 17:43:04.599:I / qdutils(19485):需要ROI合并:1 11-27 17:43:04.599:I / qdutils(19485):左分裂= 720 11-27 17:43:04.599:I / qdutils(19485):右分裂= 720 11-27 17:43:04.609:D / OpenGLRenderer(19485):启用调试模式0 11-27 17:43:09.579:D / dalvikvm(19485):newInstance失败:否() 11-27 17:43:09.579:D / AndroidRuntime(19485):关闭VM 11-27 17:43:09.579:W / dalvikvm(19485):threadid = 1:线程退出,未捕获异常(group = 0x418efda0)

11-27 17:43:09.579:E / AndroidRuntime(19485):致命异常:主要 11-27 17:43:09.579:E / AndroidRuntime(19485):进程:com.example.droid,PID:19485 11-27 17:43:09.579:E / AndroidRuntime(19485):java.lang.RuntimeException:无法实例化活动ComponentInfo {com.example.droid / com.example.droid.playlist}:java.lang.InstantiationException:can实例化类com.example.droid.playlist;没有空的构造函数 11-27 17:43:09.579:E / AndroidRuntime(19485):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2408) 11-27 17:43:09.579:E / AndroidRuntime(19485):在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2599) 11-27 17:43:09.579:E / AndroidRuntime(19485):在android.app.ActivityThread.access $ 900(ActivityThread.java:174) 11-27 17:43:09.579:E / AndroidRuntime(19485):在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1321) 11-27 17:43:09.579:E / AndroidRuntime(19485):在android.os.Handler.dispatchMessage(Handler.java:102) 11-27 17:43:09.579:E / AndroidRuntime(19485):在android.os.Looper.loop(Looper.java:146) 11-27 17:43:09.579:E / AndroidRuntime(19485):在android.app.ActivityThread.main(ActivityThread.java:5748) 11-27 17:43:09.579:E / AndroidRuntime(19485):at java.lang.reflect.Method.invokeNative(Native Method) 11-27 17:43:09.579:E / AndroidRuntime(19485):at java.lang.reflect.Method.invoke(Method.java:515) 11-27 17:43:09.579:E / AndroidRuntime(19485):at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:1291) 11-27 17:43:09.579:E / AndroidRuntime(19485):at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107) 11-27 17:43:09.579:E / AndroidRuntime(19485):at dalvik.system.NativeStart.main(Native Method) 11-27 17:43:09.579:E / AndroidRuntime(19485):引起:java.lang.InstantiationException:无法实例化类com.example.droid.playlist;没有空的构造函数 11-27 17:43:09.579:E / AndroidRuntime(19485):at java.lang.Class.newInstanceImpl(Native Method) 11-27 17:43:09.579:E / AndroidRuntime(19485):at java.lang.Class.newInstance(Class.java:1208) 11-27 17:43:09.579:E / AndroidRuntime(19485):在android.app.Instrumentation.newActivity(Instrumentation.java:1067) 11-27 17:43:09.579:E / AndroidRuntime(19485):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2399) 11-27 17:43:09.579:E / AndroidRuntime(19485):... 11更多 11-27 17:43:12.009:I / Process(19485):发送信号。 PID:19485 SIG:9

1 个答案:

答案 0 :(得分:0)

logcat输出表明你的playlist类中没有空构造函数,你必须定义它。