public void SendMail(MemoryStream stream) { SaveExcel(stream); Intent emailIntent = new Intent(Intent.ActionSend); emailIntent.SetType("plain/text"); Java.IO.File root = Android.OS.Environment.GetExternalStoragePublicDirectory("Syncfusion"); Java.IO.File file = new Java.IO.File(root, "report.xlsx"); if (file.Exists() || file.CanRead()) { Android.Net.Uri uri = Android.Net.Uri.FromFile(file); emailIntent.PutExtra(Intent.ExtraStream, uri); } Forms.Context.StartActivity(Intent.CreateChooser(emailIntent, "Send mail...")); }
private void getDir(String dirPath, Context context) { myPath.Text = "Location: " + dirPath; item = new List <String>(); path = new List <String>(); Java.IO.File f = new Java.IO.File(dirPath); Java.IO.File[] files = f.ListFiles(); if (!dirPath.Equals(root)) { item.Add(root); path.Add(root); item.Add("../"); path.Add(f.Parent); } for (int i = 0; i < files.Length; i++) { Java.IO.File file = files[i]; if (!file.IsHidden && file.CanRead()) { path.Add(file.Path); if (file.IsDirectory) { item.Add(file.Name + "/"); } else { item.Add(file.Name); } } } ArrayAdapter <String> fileList = new ArrayAdapter <String>(context, Android.Resource.Layout.SimpleListItem1, item); }
/** * Tests extraction from an MP4 to a series of PNG files. * <p> * We scale the video to 640x480 for the PNG just to demonstrate that we can scale the * video with the GPU. If the input video has a different aspect ratio, we could preserve * it by adjusting the GL viewport to get letterboxing or pillarboxing, but generally if * you're extracting frames you don't want black bars. */ public void extractMpegFrames(int saveWidth, int saveHeight) { MediaCodec decoder = null; CodecOutputSurface outputSurface = null; MediaExtractor extractor = null; try { // must be an absolute path The MediaExtractor error messages aren't very useful. Check to see if the input file exists so we can throw a better one if it's not there. File inputFile = new File(_filesdir, INPUT_FILE); if (!inputFile.CanRead()) { throw new FileNotFoundException("Unable to read " + inputFile); } extractor = new MediaExtractor(); extractor.SetDataSource(inputFile.ToString()); int trackIndex = selectTrack(extractor); if (trackIndex < 0) { throw new RuntimeException("No video track found in " + inputFile); } extractor.SelectTrack(trackIndex); MediaFormat format = extractor.GetTrackFormat(trackIndex); if (VERBOSE) { Log.Info(TAG, "Video size is " + format.GetInteger(MediaFormat.KeyWidth) + "x" + format.GetInteger(MediaFormat.KeyHeight)); } // Could use width/height from the MediaFormat to get full-size frames. outputSurface = new CodecOutputSurface(saveWidth, saveHeight); // Create a MediaCodec decoder, and configure it with the MediaFormat from the // extractor. It's very important to use the format from the extractor because // it contains a copy of the CSD-0/CSD-1 codec-specific data chunks. String mime = format.GetString(MediaFormat.KeyMime); decoder = MediaCodec.CreateDecoderByType(mime); decoder.Configure(format, outputSurface.getSurface(), null, 0); decoder.Start(); doExtract(extractor, trackIndex, decoder, outputSurface); } finally { // release everything we grabbed if (outputSurface != null) { outputSurface.release(); outputSurface = null; } if (decoder != null) { decoder.Stop(); decoder.Release(); decoder = null; } if (extractor != null) { extractor.Release(); extractor = null; } } }