Andyjava 0 Newbie Poster

I have been busy with school and all that and currently working on an android multimedia app i'd like to use. i created a list and was able to filter the files on the sdcard (both .mp3s and .mp4s) but i have a problem. i want the app to launch activities i created (HomeaudioActivity, which deals with .mp3 files and HomevideoActivity, which deals with video files) when selected from the list (i created a class and called it "AllMediaActivity". in this activity, the whole media files have been pulled from the sdcard) based on its extension.

please i'm confused at this, i wrote some codes and i'm stuck at somewhere. below is the code with the issue, please where did i go wrong?

package com.src.imagine.playmedia;

import java.util.ArrayList;
import java.util.HashMap;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.Toast;


public class AllPlayListActivity extends SherlockListActivity {
    // All the lists
    public ArrayList<HashMap<String, String>> aMediaList = new ArrayList<HashMap<String, String>>();
    Intent in;

    public void onCreate(Bundle savedInstanceState) {

        ArrayList<HashMap<String, String>> aMediaListData = new ArrayList<HashMap<String, String>>();

        AllMediaManager amm = new AllMediaManager();
        // getting all the songs from sdcard
        this.aMediaList = amm.getPlayList();

        // lopping through the playlist
        for (int i = 0; i < aMediaList.size(); i++) {
            // creating new HashMap
            HashMap<String, String> media = aMediaList.get(i);

            // adding HashList to ArrayList

        // Adding menuItems to ListView
        ListAdapter adapter = new SimpleAdapter(this, aMediaListData,
                R.layout.playlist_item, new String[] { "mediaTitle" },
                new int[] { });


        // selecting single ListView item
        ListView lv = getListView();
        // listening to single listitem click
        lv.setOnItemClickListener(new OnItemClickListener() {

            public void onItemClick(AdapterView<?> parent, View view,
                    int position, long id) {
                // getting listitem index
                final int mediaIndex = position;
                class FileExtensionFilter implements FilenameFilter {
                    public boolean accept(File dir, String name) {
                        if (name.endsWith(".mp3") || name.endsWith(".MP3")) {

                            // Starting new intent
                            in = new Intent(getApplicationContext(),
                            // Sending mediaIndex to the audioPlayerActivity
                            in.putExtra("songIndex", mediaIndex);
                            setResult(100, in);
                            // closing playlistview
                        } else if (name.endsWith(".mp4")
                                || name.endsWith(".MP4")
                                || name.endsWith(".h.264 avc")
                                || name.endsWith(".H.264 AVC")
                                || name.endsWith(".h.263")
                                || name.endsWith(".H.263")
                                || name.endsWith(".mpeg-4 sp")
                                || name.endsWith(".MPEG-4 SP")
                                || name.endsWith(".mpeg-4")
                                || name.endsWith(".MPEG-4")
                                || name.endsWith(".vp8")
                                || name.endsWith(".VP8")) {

                            // Starting new Intent
                            in = new Intent(getApplicationContext(),
                            // Sending mediaIndex to the videoPlayerActivity
                            in.putExtra("videoIndex", mediaIndex);
                            setResult(100, in);
                            // closing playlistView
                        } else {
                                    "Unsupported video format",
                        return false;



Please guys i need serious help on this

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.