Force close exceptiob with playing of media files
<p>I have developed program which should get files from /sdcard1/Media folder and play all files in infinity loop one-by-one (application also should automatically start after loading Android OS). It works correctly for me, but when I had sent it for my client it made "unexceptedly exception" after playing back. I can't past stack trace into stackoverflow.com (I don't have access to client's computer), but application is very simple and may be you will see some mistakes? Thank you. </p>

<p>Main class:</p>

<pre><code>public class SimpleMediaPlayerDemoActivity extends Activity {
    /** Called when the activity is first created. */   

    private static final String REGULAR_EXPRESSION_FILE_TYPE=".*\\.(mp4|flv)";
    private static final String FOLDER_PATH="/sdcard1/Media/";

    private String[] files;
    private int count;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        getFileNames();
    }

    private void getFileNames() {

        String path=Environment.getExternalStorageDirectory().getAbsolutePath()+FOLDER_PATH;
        File root=new File(path);
        files=root.list(new FilenameFilter() {

            private Pattern pattern=Pattern.compile(REGULAR_EXPRESSION_FILE_TYPE);

            @Override
            public boolean accept(File dir, String filename) {
                // TODO Auto-generated method stub
                Log.e("1", filename);
                return pattern.matcher(filename).matches();
            }

        });

        if (files.length==0) {
            Toast.makeText(this, "There aren't files with right extension", 
                    Toast.LENGTH_LONG).show();
        }
        else {

            for (String s:files) {
                Log.e("file", s);
            }
            initializeIntent();
        }
    }

    private void initializeIntent() {

        String path=Environment.getExternalStorageDirectory().getAbsolutePath()+FOLDER_PATH;
        Intent i=new Intent(Intent.ACTION_VIEW);
        i.setDataAndType(Uri.parse(path+files[count]), "video/*");       

        if (++count==files.length) {
            count=0;
        }

        startActivityForResult(i, 100);
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent intent) {

        if (requestCode==100) {
            initializeIntent();
        }
    }
}
</code></pre>

<p>BroadcastReceiver for auto starting:</p>

<pre><code>public class AutoStart extends BroadcastReceiver{

    @Override
    public void onReceive(Context context, Intent intent) {
        // TODO Auto-generated method stub
        if (intent.getAction().equals("android.intent.action.BOOT_COMPLETED"))
        {
            Intent i=new Intent();
            i.setClass(context, SimpleMediaPlayerDemoActivity.class);
            i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(i);
        }
    }
}
</code></pre>

<p>Android manifest:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.nda.mediademo"
    android:versionCode="1"
    android:versionName="1.0" &gt;

    &lt;uses-sdk android:minSdkVersion="7" /&gt;
    &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt;

    &lt;application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" &gt;
        &lt;activity
            android:label="@string/app_name"
            android:name=".SimpleMediaPlayerDemoActivity" &gt;
            &lt;intent-filter &gt;
                &lt;action android:name="android.intent.action.MAIN" /&gt;

                &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
            &lt;/intent-filter&gt;
        &lt;/activity&gt;
        &lt;receiver android:name=".AutoStart"&gt;
            &lt;intent-filter&gt;
                &lt;action android:name="android.intent.action.BOOT_COMPLETED"&gt;&lt;/action&gt;
            &lt;/intent-filter&gt;
        &lt;/receiver&gt;            
    &lt;/application&gt;

&lt;/manifest&gt;
</code></pre>
