summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AndroidManifest.xml31
-rw-r--r--bin/AndroidManifest.xml31
-rw-r--r--bin/capture.apkbin0 -> 258435 bytes
-rw-r--r--bin/classes.dexbin0 -> 626556 bytes
-rw-r--r--bin/classes/com/example/capture/BuildConfig.classbin0 -> 347 bytes
-rw-r--r--bin/classes/com/example/capture/MainActivity.classbin0 -> 6458 bytes
-rw-r--r--bin/classes/com/example/capture/R$attr.classbin0 -> 343 bytes
-rw-r--r--bin/classes/com/example/capture/R$dimen.classbin0 -> 464 bytes
-rw-r--r--bin/classes/com/example/capture/R$drawable.classbin0 -> 410 bytes
-rw-r--r--bin/classes/com/example/capture/R$id.classbin0 -> 434 bytes
-rw-r--r--bin/classes/com/example/capture/R$layout.classbin0 -> 434 bytes
-rw-r--r--bin/classes/com/example/capture/R$menu.classbin0 -> 391 bytes
-rw-r--r--bin/classes/com/example/capture/R$string.classbin0 -> 475 bytes
-rw-r--r--bin/classes/com/example/capture/R$style.classbin0 -> 434 bytes
-rw-r--r--bin/classes/com/example/capture/R.classbin0 -> 683 bytes
-rw-r--r--bin/dexedLibs/android-support-v4-96cf90bc600ae91b8934fcabf6ab47e4.jarbin0 -> 211326 bytes
-rw-r--r--bin/res/drawable-hdpi/ic_launcher.pngbin0 -> 5964 bytes
-rw-r--r--bin/res/drawable-mdpi/ic_launcher.pngbin0 -> 3112 bytes
-rw-r--r--bin/res/drawable-xhdpi/ic_launcher.pngbin0 -> 9355 bytes
-rw-r--r--bin/res/drawable-xxhdpi/ic_launcher.pngbin0 -> 17889 bytes
-rw-r--r--bin/resources.ap_bin0 -> 41375 bytes
-rw-r--r--gen/com/example/capture/BuildConfig.java6
-rw-r--r--gen/com/example/capture/R.java70
-rw-r--r--ic_launcher-web.pngbin0 -> 51394 bytes
-rw-r--r--libs/android-support-v4.jarbin0 -> 556198 bytes
-rw-r--r--lint.xml3
-rw-r--r--proguard-project.txt20
-rw-r--r--project.properties14
-rw-r--r--res/drawable-hdpi/ic_launcher.pngbin0 -> 7658 bytes
-rw-r--r--res/drawable-mdpi/ic_launcher.pngbin0 -> 3777 bytes
-rw-r--r--res/drawable-xhdpi/ic_launcher.pngbin0 -> 12516 bytes
-rw-r--r--res/drawable-xxhdpi/ic_launcher.pngbin0 -> 24777 bytes
-rw-r--r--res/layout/activity_main.xml16
-rw-r--r--res/layout/main.xml8
-rw-r--r--res/menu/main.xml9
-rw-r--r--res/values-sw600dp/dimens.xml8
-rw-r--r--res/values-sw720dp-land/dimens.xml9
-rw-r--r--res/values-v11/styles.xml11
-rw-r--r--res/values-v14/styles.xml12
-rw-r--r--res/values/dimens.xml7
-rw-r--r--res/values/strings.xml8
-rw-r--r--res/values/styles.xml20
-rw-r--r--src/com/example/capture/MainActivity.java201
43 files changed, 484 insertions, 0 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
new file mode 100644
index 0000000..a49fde4
--- /dev/null
+++ b/AndroidManifest.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.example.capture"
+ android:versionCode="1"
+ android:versionName="1.0" >
+
+ <uses-sdk
+ android:minSdkVersion="8"
+ android:targetSdkVersion="17" />
+
+ <uses-permission android:name="android.permission.CAMERA"/>
+ <uses-permission android:name="android.permission.RECORD_AUDIO" />
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+
+ <application
+ android:allowBackup="true"
+ android:icon="@drawable/ic_launcher"
+ android:label="@string/app_name"
+ android:theme="@style/AppTheme" >
+ <activity
+ android:name="com.example.capture.MainActivity"
+ android:label="@string/app_name" >
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ </application>
+
+</manifest>
diff --git a/bin/AndroidManifest.xml b/bin/AndroidManifest.xml
new file mode 100644
index 0000000..a49fde4
--- /dev/null
+++ b/bin/AndroidManifest.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.example.capture"
+ android:versionCode="1"
+ android:versionName="1.0" >
+
+ <uses-sdk
+ android:minSdkVersion="8"
+ android:targetSdkVersion="17" />
+
+ <uses-permission android:name="android.permission.CAMERA"/>
+ <uses-permission android:name="android.permission.RECORD_AUDIO" />
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+
+ <application
+ android:allowBackup="true"
+ android:icon="@drawable/ic_launcher"
+ android:label="@string/app_name"
+ android:theme="@style/AppTheme" >
+ <activity
+ android:name="com.example.capture.MainActivity"
+ android:label="@string/app_name" >
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ </application>
+
+</manifest>
diff --git a/bin/capture.apk b/bin/capture.apk
new file mode 100644
index 0000000..142bd1f
--- /dev/null
+++ b/bin/capture.apk
Binary files differ
diff --git a/bin/classes.dex b/bin/classes.dex
new file mode 100644
index 0000000..b480214
--- /dev/null
+++ b/bin/classes.dex
Binary files differ
diff --git a/bin/classes/com/example/capture/BuildConfig.class b/bin/classes/com/example/capture/BuildConfig.class
new file mode 100644
index 0000000..608ca5d
--- /dev/null
+++ b/bin/classes/com/example/capture/BuildConfig.class
Binary files differ
diff --git a/bin/classes/com/example/capture/MainActivity.class b/bin/classes/com/example/capture/MainActivity.class
new file mode 100644
index 0000000..dbe56d4
--- /dev/null
+++ b/bin/classes/com/example/capture/MainActivity.class
Binary files differ
diff --git a/bin/classes/com/example/capture/R$attr.class b/bin/classes/com/example/capture/R$attr.class
new file mode 100644
index 0000000..80190fd
--- /dev/null
+++ b/bin/classes/com/example/capture/R$attr.class
Binary files differ
diff --git a/bin/classes/com/example/capture/R$dimen.class b/bin/classes/com/example/capture/R$dimen.class
new file mode 100644
index 0000000..cfd9b91
--- /dev/null
+++ b/bin/classes/com/example/capture/R$dimen.class
Binary files differ
diff --git a/bin/classes/com/example/capture/R$drawable.class b/bin/classes/com/example/capture/R$drawable.class
new file mode 100644
index 0000000..64fa271
--- /dev/null
+++ b/bin/classes/com/example/capture/R$drawable.class
Binary files differ
diff --git a/bin/classes/com/example/capture/R$id.class b/bin/classes/com/example/capture/R$id.class
new file mode 100644
index 0000000..28a8a90
--- /dev/null
+++ b/bin/classes/com/example/capture/R$id.class
Binary files differ
diff --git a/bin/classes/com/example/capture/R$layout.class b/bin/classes/com/example/capture/R$layout.class
new file mode 100644
index 0000000..6d0f64d
--- /dev/null
+++ b/bin/classes/com/example/capture/R$layout.class
Binary files differ
diff --git a/bin/classes/com/example/capture/R$menu.class b/bin/classes/com/example/capture/R$menu.class
new file mode 100644
index 0000000..b6e0704
--- /dev/null
+++ b/bin/classes/com/example/capture/R$menu.class
Binary files differ
diff --git a/bin/classes/com/example/capture/R$string.class b/bin/classes/com/example/capture/R$string.class
new file mode 100644
index 0000000..6274096
--- /dev/null
+++ b/bin/classes/com/example/capture/R$string.class
Binary files differ
diff --git a/bin/classes/com/example/capture/R$style.class b/bin/classes/com/example/capture/R$style.class
new file mode 100644
index 0000000..dda8175
--- /dev/null
+++ b/bin/classes/com/example/capture/R$style.class
Binary files differ
diff --git a/bin/classes/com/example/capture/R.class b/bin/classes/com/example/capture/R.class
new file mode 100644
index 0000000..c74d8b1
--- /dev/null
+++ b/bin/classes/com/example/capture/R.class
Binary files differ
diff --git a/bin/dexedLibs/android-support-v4-96cf90bc600ae91b8934fcabf6ab47e4.jar b/bin/dexedLibs/android-support-v4-96cf90bc600ae91b8934fcabf6ab47e4.jar
new file mode 100644
index 0000000..b5785b4
--- /dev/null
+++ b/bin/dexedLibs/android-support-v4-96cf90bc600ae91b8934fcabf6ab47e4.jar
Binary files differ
diff --git a/bin/res/drawable-hdpi/ic_launcher.png b/bin/res/drawable-hdpi/ic_launcher.png
new file mode 100644
index 0000000..efa7c5f
--- /dev/null
+++ b/bin/res/drawable-hdpi/ic_launcher.png
Binary files differ
diff --git a/bin/res/drawable-mdpi/ic_launcher.png b/bin/res/drawable-mdpi/ic_launcher.png
new file mode 100644
index 0000000..ec27f2e
--- /dev/null
+++ b/bin/res/drawable-mdpi/ic_launcher.png
Binary files differ
diff --git a/bin/res/drawable-xhdpi/ic_launcher.png b/bin/res/drawable-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..92fc57d
--- /dev/null
+++ b/bin/res/drawable-xhdpi/ic_launcher.png
Binary files differ
diff --git a/bin/res/drawable-xxhdpi/ic_launcher.png b/bin/res/drawable-xxhdpi/ic_launcher.png
new file mode 100644
index 0000000..b6f8f4e
--- /dev/null
+++ b/bin/res/drawable-xxhdpi/ic_launcher.png
Binary files differ
diff --git a/bin/resources.ap_ b/bin/resources.ap_
new file mode 100644
index 0000000..884fc04
--- /dev/null
+++ b/bin/resources.ap_
Binary files differ
diff --git a/gen/com/example/capture/BuildConfig.java b/gen/com/example/capture/BuildConfig.java
new file mode 100644
index 0000000..63b07e4
--- /dev/null
+++ b/gen/com/example/capture/BuildConfig.java
@@ -0,0 +1,6 @@
+/** Automatically generated file. DO NOT MODIFY */
+package com.example.capture;
+
+public final class BuildConfig {
+ public final static boolean DEBUG = true;
+} \ No newline at end of file
diff --git a/gen/com/example/capture/R.java b/gen/com/example/capture/R.java
new file mode 100644
index 0000000..56e9848
--- /dev/null
+++ b/gen/com/example/capture/R.java
@@ -0,0 +1,70 @@
+/* AUTO-GENERATED FILE. DO NOT MODIFY.
+ *
+ * This class was automatically generated by the
+ * aapt tool from the resource data it found. It
+ * should not be modified by hand.
+ */
+
+package com.example.capture;
+
+public final class R {
+ public static final class attr {
+ }
+ public static final class dimen {
+ /** Default screen margins, per the Android Design guidelines.
+
+ Customize dimensions originally defined in res/values/dimens.xml (such as
+ screen margins) for sw720dp devices (e.g. 10" tablets) in landscape here.
+
+ */
+ public static final int activity_horizontal_margin=0x7f040000;
+ public static final int activity_vertical_margin=0x7f040001;
+ }
+ public static final class drawable {
+ public static final int ic_launcher=0x7f020000;
+ }
+ public static final class id {
+ public static final int action_settings=0x7f080001;
+ public static final int surface_camera=0x7f080000;
+ }
+ public static final class layout {
+ public static final int activity_main=0x7f030000;
+ public static final int main=0x7f030001;
+ }
+ public static final class menu {
+ public static final int main=0x7f070000;
+ }
+ public static final class string {
+ public static final int action_settings=0x7f050001;
+ public static final int app_name=0x7f050000;
+ public static final int hello_world=0x7f050002;
+ }
+ public static final class style {
+ /**
+ Base application theme, dependent on API level. This theme is replaced
+ by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
+
+
+ Theme customizations available in newer API levels can go in
+ res/values-vXX/styles.xml, while customizations related to
+ backward-compatibility can go here.
+
+
+ Base application theme for API 11+. This theme completely replaces
+ AppBaseTheme from res/values/styles.xml on API 11+ devices.
+
+ API 11 theme customizations can go here.
+
+ Base application theme for API 14+. This theme completely replaces
+ AppBaseTheme from BOTH res/values/styles.xml and
+ res/values-v11/styles.xml on API 14+ devices.
+
+ API 14 theme customizations can go here.
+ */
+ public static final int AppBaseTheme=0x7f060000;
+ /** Application theme.
+ All customizations that are NOT specific to a particular API-level can go here.
+ */
+ public static final int AppTheme=0x7f060001;
+ }
+}
diff --git a/ic_launcher-web.png b/ic_launcher-web.png
new file mode 100644
index 0000000..a18cbb4
--- /dev/null
+++ b/ic_launcher-web.png
Binary files differ
diff --git a/libs/android-support-v4.jar b/libs/android-support-v4.jar
new file mode 100644
index 0000000..cf12d28
--- /dev/null
+++ b/libs/android-support-v4.jar
Binary files differ
diff --git a/lint.xml b/lint.xml
new file mode 100644
index 0000000..ee0eead
--- /dev/null
+++ b/lint.xml
@@ -0,0 +1,3 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<lint>
+</lint> \ No newline at end of file
diff --git a/proguard-project.txt b/proguard-project.txt
new file mode 100644
index 0000000..f2fe155
--- /dev/null
+++ b/proguard-project.txt
@@ -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 *;
+#}
diff --git a/project.properties b/project.properties
new file mode 100644
index 0000000..ce39f2d
--- /dev/null
+++ b/project.properties
@@ -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-18
diff --git a/res/drawable-hdpi/ic_launcher.png b/res/drawable-hdpi/ic_launcher.png
new file mode 100644
index 0000000..288b665
--- /dev/null
+++ b/res/drawable-hdpi/ic_launcher.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_launcher.png b/res/drawable-mdpi/ic_launcher.png
new file mode 100644
index 0000000..6ae570b
--- /dev/null
+++ b/res/drawable-mdpi/ic_launcher.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_launcher.png b/res/drawable-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..d4fb7cd
--- /dev/null
+++ b/res/drawable-xhdpi/ic_launcher.png
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_launcher.png b/res/drawable-xxhdpi/ic_launcher.png
new file mode 100644
index 0000000..85a6081
--- /dev/null
+++ b/res/drawable-xxhdpi/ic_launcher.png
Binary files differ
diff --git a/res/layout/activity_main.xml b/res/layout/activity_main.xml
new file mode 100644
index 0000000..168c9b8
--- /dev/null
+++ b/res/layout/activity_main.xml
@@ -0,0 +1,16 @@
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:paddingBottom="@dimen/activity_vertical_margin"
+ android:paddingLeft="@dimen/activity_horizontal_margin"
+ android:paddingRight="@dimen/activity_horizontal_margin"
+ android:paddingTop="@dimen/activity_vertical_margin"
+ tools:context=".MainActivity" >
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/hello_world" />
+
+</RelativeLayout>
diff --git a/res/layout/main.xml b/res/layout/main.xml
new file mode 100644
index 0000000..b64d0eb
--- /dev/null
+++ b/res/layout/main.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<SurfaceView android:id="@+id/surface_camera" xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:layout_centerInParent="true"
+ android:layout_weight="1"
+ >
+</SurfaceView> \ No newline at end of file
diff --git a/res/menu/main.xml b/res/menu/main.xml
new file mode 100644
index 0000000..c002028
--- /dev/null
+++ b/res/menu/main.xml
@@ -0,0 +1,9 @@
+<menu xmlns:android="http://schemas.android.com/apk/res/android" >
+
+ <item
+ android:id="@+id/action_settings"
+ android:orderInCategory="100"
+ android:showAsAction="never"
+ android:title="@string/action_settings"/>
+
+</menu>
diff --git a/res/values-sw600dp/dimens.xml b/res/values-sw600dp/dimens.xml
new file mode 100644
index 0000000..44f01db
--- /dev/null
+++ b/res/values-sw600dp/dimens.xml
@@ -0,0 +1,8 @@
+<resources>
+
+ <!--
+ Customize dimensions originally defined in res/values/dimens.xml (such as
+ screen margins) for sw600dp devices (e.g. 7" tablets) here.
+ -->
+
+</resources>
diff --git a/res/values-sw720dp-land/dimens.xml b/res/values-sw720dp-land/dimens.xml
new file mode 100644
index 0000000..61e3fa8
--- /dev/null
+++ b/res/values-sw720dp-land/dimens.xml
@@ -0,0 +1,9 @@
+<resources>
+
+ <!--
+ Customize dimensions originally defined in res/values/dimens.xml (such as
+ screen margins) for sw720dp devices (e.g. 10" tablets) in landscape here.
+ -->
+ <dimen name="activity_horizontal_margin">128dp</dimen>
+
+</resources>
diff --git a/res/values-v11/styles.xml b/res/values-v11/styles.xml
new file mode 100644
index 0000000..3c02242
--- /dev/null
+++ b/res/values-v11/styles.xml
@@ -0,0 +1,11 @@
+<resources>
+
+ <!--
+ Base application theme for API 11+. This theme completely replaces
+ AppBaseTheme from res/values/styles.xml on API 11+ devices.
+ -->
+ <style name="AppBaseTheme" parent="android:Theme.Holo.Light">
+ <!-- API 11 theme customizations can go here. -->
+ </style>
+
+</resources>
diff --git a/res/values-v14/styles.xml b/res/values-v14/styles.xml
new file mode 100644
index 0000000..a91fd03
--- /dev/null
+++ b/res/values-v14/styles.xml
@@ -0,0 +1,12 @@
+<resources>
+
+ <!--
+ Base application theme for API 14+. This theme completely replaces
+ AppBaseTheme from BOTH res/values/styles.xml and
+ res/values-v11/styles.xml on API 14+ devices.
+ -->
+ <style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
+ <!-- API 14 theme customizations can go here. -->
+ </style>
+
+</resources>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
new file mode 100644
index 0000000..55c1e59
--- /dev/null
+++ b/res/values/dimens.xml
@@ -0,0 +1,7 @@
+<resources>
+
+ <!-- Default screen margins, per the Android Design guidelines. -->
+ <dimen name="activity_horizontal_margin">16dp</dimen>
+ <dimen name="activity_vertical_margin">16dp</dimen>
+
+</resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
new file mode 100644
index 0000000..8b9e6e4
--- /dev/null
+++ b/res/values/strings.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+
+ <string name="app_name">capture</string>
+ <string name="action_settings">Settings</string>
+ <string name="hello_world">Hello world!</string>
+
+</resources>
diff --git a/res/values/styles.xml b/res/values/styles.xml
new file mode 100644
index 0000000..6ce89c7
--- /dev/null
+++ b/res/values/styles.xml
@@ -0,0 +1,20 @@
+<resources>
+
+ <!--
+ Base application theme, dependent on API level. This theme is replaced
+ by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
+ -->
+ <style name="AppBaseTheme" parent="android:Theme.Light">
+ <!--
+ Theme customizations available in newer API levels can go in
+ res/values-vXX/styles.xml, while customizations related to
+ backward-compatibility can go here.
+ -->
+ </style>
+
+ <!-- Application theme. -->
+ <style name="AppTheme" parent="AppBaseTheme">
+ <!-- All customizations that are NOT specific to a particular API-level can go here. -->
+ </style>
+
+</resources>
diff --git a/src/com/example/capture/MainActivity.java b/src/com/example/capture/MainActivity.java
new file mode 100644
index 0000000..b6e96de
--- /dev/null
+++ b/src/com/example/capture/MainActivity.java
@@ -0,0 +1,201 @@
+package com.example.capture;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Date;
+import android.app.Activity;
+import android.content.Intent;
+import android.hardware.Camera;
+import android.hardware.Camera.Parameters;
+import android.media.MediaRecorder;
+import android.net.Uri;
+import android.os.Bundle;
+import android.os.Environment;
+import android.util.Log;
+import android.view.MenuItem;
+import android.view.SurfaceHolder;
+import android.view.SurfaceHolder.Callback;
+import android.view.Menu;
+import android.view.SurfaceView;
+import android.widget.Toast;
+
+//http://stackoverflow.com/questions/17042308/select-a-music-file-to-play-with-mediaplayer
+//http://stackoverflow.com/questions/2709087/turning-a-string-into-a-uri-android
+
+public class MainActivity extends Activity implements Callback {
+
+ @Override
+ protected void onDestroy() {
+ stopRecording();
+ super.onDestroy();
+ }
+
+ private SurfaceHolder surfaceHolder;
+ private SurfaceView surfaceView;
+ public MediaRecorder mrec = new MediaRecorder();
+ private Camera mCamera;
+ private Uri uriSound;
+
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.main);
+
+ surfaceView = (SurfaceView) findViewById(R.id.surface_camera);
+
+ mCamera = Camera.open();
+
+ surfaceHolder = surfaceView.getHolder();
+ surfaceHolder.addCallback(this);
+ surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
+
+ uriSound=Uri.parse("");
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu)
+ {
+
+ menu.add(0, 0, 0, "Start");
+ menu.add(0, 0, 0, "Pick audio track");
+ return super.onCreateOptionsMenu(menu);
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item)
+ {
+ if(item.getTitle().equals("Start"))
+ {
+ try {
+
+ startRecording();
+ item.setTitle("Stop");
+
+ } catch (Exception e) {
+
+ String message = e.getMessage();
+ Log.i(null, "Problem " + message);
+ mrec.release();
+ }
+
+ }
+ else if(item.getTitle().equals("Stop"))
+ {
+ mrec.stop();
+ mrec.release();
+ mrec = null;
+ item.setTitle("Start");
+ }
+ else if(item.getTitle().equals("Pick audio track"))
+ {
+ Intent intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Audio.Media.EXTERNAL_CONTENT_URI);
+ startActivityForResult(intent, 10);
+ }
+
+ return super.onOptionsItemSelected(item);
+ }
+
+ protected void startRecording() throws IOException
+ {
+ if(mCamera==null)
+ mCamera = Camera.open();
+
+ String filename;
+ String path;
+
+ path= Environment.getExternalStorageDirectory().getAbsolutePath().toString();
+
+ Date date=new Date();
+ filename="/rec"+date.toString().replace(" ", "_").replace(":", "_")+".mp4";
+
+ //create empty file it must use
+ File file=new File(path,filename);
+
+ mrec = new MediaRecorder();
+
+ mCamera.lock();
+ mCamera.unlock();
+
+ // Please maintain sequence of following code.
+
+ // If you change sequence it will not work.
+ mrec.setCamera(mCamera);
+ mrec.setVideoSource(MediaRecorder.VideoSource.CAMERA);
+ mrec.setAudioSource(MediaRecorder.AudioSource.MIC);
+ mrec.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
+ mrec.setVideoEncoder(MediaRecorder.VideoEncoder.MPEG_4_SP);
+ mrec.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
+ mrec.setPreviewDisplay(surfaceHolder.getSurface());
+ mrec.setOutputFile(path+filename);
+ mrec.prepare();
+ mrec.start();
+
+
+ }
+
+ protected void stopRecording() {
+
+ if(mrec!=null)
+ {
+ mrec.stop();
+ mrec.release();
+ mCamera.release();
+ mCamera.lock();
+ }
+ }
+
+ private void releaseMediaRecorder() {
+
+ if (mrec != null) {
+ mrec.reset(); // clear recorder configuration
+ mrec.release(); // release the recorder object
+ }
+ }
+
+ private void releaseCamera() {
+ if (mCamera != null) {
+ mCamera.release(); // release the camera for other applications
+ mCamera = null;
+ }
+
+ }
+
+ @Override
+ public void surfaceChanged(SurfaceHolder holder, int format, int width,int height) {
+
+ }
+
+ @Override
+ public void surfaceCreated(SurfaceHolder holder) {
+
+ if (mCamera != null) {
+ Parameters params = mCamera.getParameters();
+ mCamera.setParameters(params);
+ Log.i("Surface", "Created");
+ }
+ else {
+ Toast.makeText(getApplicationContext(), "Camera not available!",
+ Toast.LENGTH_LONG).show();
+
+ finish();
+ }
+
+ }
+
+ @Override
+ public void surfaceDestroyed(SurfaceHolder holder) {
+ mCamera.stopPreview();
+ mCamera.release();
+ //http://stackoverflow.com/questions/13235306/method-called-after-release-exception-camera-preview
+ //mCamera=null;
+ }
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+
+ if(requestCode == RESULT_OK && requestCode == 10){
+ uriSound=data.getData();
+ }
+ }
+}