I'm trying to play video's on Android, by launching an intent.
The code I'm using is:
tostart = new Intent(Intent.ACTION_VIEW);
tostart.setDataAndType(Uri.parse(movieurl), "video/*");
startActivity(tostart);
This works on most phones, but not on the HTC Hero. It seems to load a bit different video player. This does play the first video thrown at it. However, every video after that it doesn't respond. (it keeps in some loop).
If I add an explicit
tostart.setClassName("com.htc.album","com.htc.album.ViewVideo");
(before the startactivity) it does work on the HTC Hero. However, since this is a HTC specific call, I can't run this code on other phones (such as the G1).
On the G1, this works:
tostart.setClassName("com.android.camera","com.android.camera.MovieView"); //g1 version
But this intent is missing from the hero.
Does anybody know a list of intents/classnames that should be supported by all Android devices? Or a specific one to launch a video?
Thanks!
Best Answer
Use setDataAndType on the Intent
Use "video/mp4" as MIME or use "video/*" if you don't know the type.
Edit: This not valid for general use. It fixes a bug in old HTC devices which required the URI in both the intent constructor and be set afterwards.