本帖最后由 zhangjingweizhang 于 2014-08-27 14:16:32 编辑

解决方案 »

  1.   

    越界访问!检测一下MainActivity中,有没有空的 数组或集合,如果为空不能读取元素。
      

  2.   

    检查oncreate中是否有array或list越界操作。
      

  3.   


    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    // getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
    // WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_main);
    MyApplication.getInstance().addActivity(this);
    context = this;
    inflater = LayoutInflater.from(this);
    // 获取上次退出时的播放位置
    initView();
    startService(new Intent(context, MusicPlayerService.class));
    // 启动service
    Intent intent = new Intent(this, DownloadService.class);
    startService(intent);
    this.getApplicationContext()
    .bindService(intent, conn, BIND_AUTO_CREATE);
    // 创建音乐目录
    if (Environment.getExternalStorageState().equals(
    Environment.MEDIA_MOUNTED)) {
    File root = Environment.getExternalStorageDirectory();
    dir = new File(root, "TMusic");
    if (!dir.exists()) {
    dir.mkdir();
    }
    }
    myReciver = new MusicReciver();
    reciver = new refreshReciver();
    groupDao = new MusicGroupDao(context);
    }
      

  4.   


    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    // getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
    // WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_main);
    MyApplication.getInstance().addActivity(this);
    context = this;
    inflater = LayoutInflater.from(this);
    // 获取上次退出时的播放位置
    initView();
    startService(new Intent(context, MusicPlayerService.class));
    // 启动service
    Intent intent = new Intent(this, DownloadService.class);
    startService(intent);
    this.getApplicationContext()
    .bindService(intent, conn, BIND_AUTO_CREATE);
    // 创建音乐目录
    if (Environment.getExternalStorageState().equals(
    Environment.MEDIA_MOUNTED)) {
    File root = Environment.getExternalStorageDirectory();
    dir = new File(root, "TMusic");
    if (!dir.exists()) {
    dir.mkdir();
    }
    }
    myReciver = new MusicReciver();
    reciver = new refreshReciver();
    groupDao = new MusicGroupDao(context);
    }

    initView();中做了什么