open Video File - Android Media

Android examples for Media:Video

Description

open Video File

Demo Code


//package com.java2s;

import android.content.ActivityNotFoundException;

import android.content.Context;
import android.content.Intent;

import android.net.Uri;

public class Main {
    public static boolean openVideoFile(Context a, Uri pathToVideo) {
        Intent intent = new Intent(Intent.ACTION_VIEW, pathToVideo);
        intent.setDataAndType(pathToVideo, "video/*");
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        try {//from   w  ww.j a va2 s  .  co  m
            a.startActivity(intent);
            return true;
        } catch (ActivityNotFoundException e) {
        }
        return false;
    }
}

Related Tutorials