Permalink
Browse files

example of recording video by Intent

  • Loading branch information...
1 parent 03b4b45 commit f848f93fda0da34c8803eabbeaf35db8cf22af31 @commonsguy committed Nov 18, 2013
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="gen"/>
+ <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
+ <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
+ <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
+ <classpathentry kind="output" path="bin/classes"/>
+</classpath>
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>VideoRecordingIntent</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.ApkBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>com.android.ide.eclipse.adt.AndroidNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
@@ -0,0 +1,36 @@
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.commonsware.android.videorecord"
+ android:versionCode="1"
+ android:versionName="1.0">
+
+ <uses-sdk
+ android:minSdkVersion="8"
+ android:targetSdkVersion="15"/>
+
+ <supports-screens
+ android:largeScreens="true"
+ android:normalScreens="true"
+ android:smallScreens="true"/>
+
+ <uses-feature
+ android:name="android.hardware.microphone"
+ android:required="true"/>
+ <uses-feature
+ android:name="android.hardware.camera"
+ android:required="true"/>
+
+ <application
+ android:icon="@drawable/ic_launcher"
+ android:label="@string/app_name">
+ <activity
+ android:name="MainActivity"
+ android:label="@string/title_activity_main" android:theme="@android:style/Theme.NoDisplay">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN"/>
+
+ <category android:name="android.intent.category.LAUNCHER"/>
+ </intent-filter>
+ </activity>
+ </application>
+
+</manifest>
Binary file not shown.
@@ -0,0 +1,20 @@
+# To enable ProGuard in your project, edit project.properties
+# to define the proguard.config property as described in that file.
+#
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in ${sdk.dir}/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the ProGuard
+# include property in project.properties.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
@@ -0,0 +1,14 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system edit
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+#
+# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
+#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
+
+# Project target.
+target=android-10
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,6 @@
+<ToggleButton xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:id="@+id/record"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:textAppearance="?android:attr/textAppearanceLarge"/>
@@ -0,0 +1,10 @@
+<resources>
+
+ <string name="app_name">Audio Recording Demo</string>
+ <string name="title_activity_main">Audio Recording</string>
+ <string name="record">Record</string>
+ <string name="strange">Something strange happened</string>
+ <string name="max_duration">Maximum duration reached</string>
+ <string name="max_size">Maximum file size reached</string>
+
+</resources>
@@ -0,0 +1,5 @@
+<resources>
+
+ <style name="AppTheme" parent="android:Theme.Light"/>
+
+</resources>
@@ -0,0 +1,64 @@
+/***
+ Copyright (c) 2013 CommonsWare, LLC
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ use this file except in compliance with the License. You may obtain a copy
+ of the License at http://www.apache.org/licenses/LICENSE-2.0. Unless required
+ by applicable law or agreed to in writing, software distributed under the
+ License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+ OF ANY KIND, either express or implied. See the License for the specific
+ language governing permissions and limitations under the License.
+
+ From _The Busy Coder's Guide to Android Development_
+ http://commonsware.com/Android
+ */
+
+package com.commonsware.android.videorecord;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.net.Uri;
+import android.os.Bundle;
+import android.os.Environment;
+import android.provider.MediaStore;
+import java.io.File;
+
+public class MainActivity extends Activity {
+ private static final int REQUEST_ID=1337;
+ private Uri result=null;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ File video=
+ new File(
+ Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES),
+ "sample.mp4");
+
+ if (video.exists()) {
+ video.delete();
+ }
+
+ Intent i=new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
+
+ result=Uri.fromFile(video);
+ i.putExtra(MediaStore.EXTRA_OUTPUT, result);
+ i.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
+
+ startActivityForResult(i, REQUEST_ID);
+ }
+
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode,
+ Intent data) {
+ if (requestCode == REQUEST_ID && resultCode == RESULT_OK) {
+ Intent view=
+ new Intent(Intent.ACTION_VIEW).setDataAndType(result,
+ "video/mp4");
+
+ startActivity(view);
+ }
+
+ finish();
+ }
+}

0 comments on commit f848f93

Please sign in to comment.