├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── ic_launcher-web.png
│ │ ├── res
│ │ │ ├── mipmap-hdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── ic_launcher_round.png
│ │ │ │ └── ic_launcher_foreground.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── ic_launcher_round.png
│ │ │ │ └── ic_launcher_foreground.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── ic_launcher_round.png
│ │ │ │ └── ic_launcher_foreground.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── ic_launcher_round.png
│ │ │ │ └── ic_launcher_foreground.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── ic_launcher_round.png
│ │ │ │ └── ic_launcher_foreground.png
│ │ │ ├── values
│ │ │ │ ├── dimens.xml
│ │ │ │ ├── colors.xml
│ │ │ │ ├── strings.xml
│ │ │ │ └── styles.xml
│ │ │ ├── xml
│ │ │ │ └── file_paths.xml
│ │ │ ├── mipmap-anydpi-v26
│ │ │ │ ├── ic_launcher.xml
│ │ │ │ └── ic_launcher_round.xml
│ │ │ ├── menu
│ │ │ │ └── menu_main.xml
│ │ │ ├── layout
│ │ │ │ ├── activity_main.xml
│ │ │ │ └── content_main.xml
│ │ │ ├── drawable-v24
│ │ │ │ └── ic_launcher_foreground.xml
│ │ │ └── drawable
│ │ │ │ └── ic_launcher_background.xml
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ │ └── info
│ │ │ └── androidhive
│ │ │ └── androidcamera
│ │ │ ├── CameraUtils.java
│ │ │ └── MainActivity.java
│ ├── test
│ │ └── java
│ │ │ └── info
│ │ │ └── androidhive
│ │ │ └── androidcamera
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── info
│ │ └── androidhive
│ │ └── androidcamera
│ │ └── ExampleInstrumentedTest.java
├── proguard-rules.pro
└── build.gradle
├── settings.gradle
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .idea
├── vcs.xml
├── modules.xml
├── runConfigurations.xml
├── codeStyles
│ └── Project.xml
└── misc.xml
├── README.md
├── gradle.properties
├── .gitignore
├── gradlew.bat
└── gradlew
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/app/src/main/ic_launcher-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ravi8x/AndroidCamera/HEAD/app/src/main/ic_launcher-web.png
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ravi8x/AndroidCamera/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ravi8x/AndroidCamera/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ravi8x/AndroidCamera/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ravi8x/AndroidCamera/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ravi8x/AndroidCamera/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ravi8x/AndroidCamera/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ravi8x/AndroidCamera/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ravi8x/AndroidCamera/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ravi8x/AndroidCamera/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ravi8x/AndroidCamera/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ravi8x/AndroidCamera/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 | 16dp
3 | 8dp
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ravi8x/AndroidCamera/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ravi8x/AndroidCamera/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ravi8x/AndroidCamera/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ravi8x/AndroidCamera/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ravi8x/AndroidCamera/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/file_paths.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #1fb49c
4 | #1fb49c
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed May 23 22:51:24 IST 2018
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
7 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Android integrating Camera feature using in-build camera app.
2 |
3 | [Tutorial](https://www.androidhive.info/2013/09/android-working-with-camera-api/)
4 |
5 | [Apk](http://download.androidhive.info/apk/android-camera.apk)
6 |
7 | 
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Android Camera
3 | Settings
4 | Image and Video preview will appear here
5 | Take Picture
6 | Record Video
7 |
8 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
11 |
--------------------------------------------------------------------------------
/app/src/test/java/info/androidhive/androidcamera/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package info.androidhive.androidcamera;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/info/androidhive/androidcamera/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package info.androidhive.androidcamera;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumented test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("info.androidhive.androidcamera", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 27
5 | defaultConfig {
6 | applicationId "info.androidhive.androidcamera"
7 | minSdkVersion 16
8 | targetSdkVersion 27
9 | versionCode 1
10 | versionName "1.0"
11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | }
20 |
21 | dependencies {
22 | implementation fileTree(dir: 'libs', include: ['*.jar'])
23 | implementation 'com.android.support:appcompat-v7:27.1.1'
24 | implementation 'com.android.support.constraint:constraint-layout:1.1.0'
25 | implementation 'com.android.support:design:27.1.1'
26 | testImplementation 'junit:junit:4.12'
27 | androidTestImplementation 'com.android.support.test:runner:1.0.2'
28 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
29 |
30 | // dexter runtime permissions
31 | implementation 'com.karumi:dexter:4.2.0'
32 | }
33 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Built application files
2 | *.apk
3 | *.ap_
4 |
5 | # Files for the ART/Dalvik VM
6 | *.dex
7 |
8 | # Java class files
9 | *.class
10 |
11 | # Generated files
12 | bin/
13 | gen/
14 | out/
15 |
16 | # Gradle files
17 | .gradle/
18 | build/
19 |
20 | # Local configuration file (sdk path, etc)
21 | local.properties
22 |
23 | # Proguard folder generated by Eclipse
24 | proguard/
25 |
26 | # Log Files
27 | *.log
28 |
29 | # Android Studio Navigation editor temp files
30 | .navigation/
31 |
32 | # Android Studio captures folder
33 | captures/
34 |
35 | # IntelliJ
36 | *.iml
37 | .idea/workspace.xml
38 | .idea/tasks.xml
39 | .idea/gradle.xml
40 | .idea/assetWizardSettings.xml
41 | .idea/dictionaries
42 | .idea/libraries
43 | .idea/caches
44 |
45 | # Keystore files
46 | # Uncomment the following line if you do not want to check your keystore files in.
47 | #*.jks
48 |
49 | # External native build folder generated in Android Studio 2.2 and later
50 | .externalNativeBuild
51 |
52 | # Google Services (e.g. APIs or Firebase)
53 | google-services.json
54 |
55 | # Freeline
56 | freeline.py
57 | freeline/
58 | freeline_project_description.json
59 |
60 | # fastlane
61 | fastlane/report.xml
62 | fastlane/Preview.html
63 | fastlane/screenshots
64 | fastlane/test_output
65 | fastlane/readme.md
66 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
12 |
13 |
20 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
36 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/content_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
19 |
20 |
28 |
29 |
30 |
36 |
37 |
38 |
44 |
45 |
46 |
51 |
52 |
53 |
63 |
64 |
65 |
75 |
76 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
10 |
12 |
14 |
16 |
18 |
20 |
22 |
24 |
26 |
28 |
30 |
32 |
34 |
36 |
38 |
40 |
42 |
44 |
46 |
48 |
50 |
52 |
54 |
56 |
58 |
60 |
62 |
64 |
66 |
68 |
70 |
72 |
74 |
75 |
--------------------------------------------------------------------------------
/app/src/main/java/info/androidhive/androidcamera/CameraUtils.java:
--------------------------------------------------------------------------------
1 | package info.androidhive.androidcamera;
2 |
3 | import android.Manifest;
4 | import android.content.Context;
5 | import android.content.Intent;
6 | import android.content.pm.PackageManager;
7 | import android.graphics.Bitmap;
8 | import android.graphics.BitmapFactory;
9 | import android.media.MediaScannerConnection;
10 | import android.net.Uri;
11 | import android.os.Environment;
12 | import android.provider.Settings;
13 | import android.support.v4.app.ActivityCompat;
14 | import android.support.v4.content.FileProvider;
15 | import android.util.Log;
16 |
17 | import java.io.File;
18 | import java.text.SimpleDateFormat;
19 | import java.util.Date;
20 | import java.util.Locale;
21 |
22 | public class CameraUtils {
23 |
24 | /**
25 | * Refreshes gallery on adding new image/video. Gallery won't be refreshed
26 | * on older devices until device is rebooted
27 | */
28 | public static void refreshGallery(Context context, String filePath) {
29 | // ScanFile so it will be appeared on Gallery
30 | MediaScannerConnection.scanFile(context,
31 | new String[]{filePath}, null,
32 | new MediaScannerConnection.OnScanCompletedListener() {
33 | public void onScanCompleted(String path, Uri uri) {
34 | }
35 | });
36 | }
37 |
38 | public static boolean checkPermissions(Context context) {
39 | return ActivityCompat.checkSelfPermission(context, Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED
40 | && ActivityCompat.checkSelfPermission(context, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED
41 | && ActivityCompat.checkSelfPermission(context, Manifest.permission.RECORD_AUDIO) == PackageManager.PERMISSION_GRANTED;
42 | }
43 |
44 | /**
45 | * Downsizing the bitmap to avoid OutOfMemory exceptions
46 | */
47 | public static Bitmap optimizeBitmap(int sampleSize, String filePath) {
48 | // bitmap factory
49 | BitmapFactory.Options options = new BitmapFactory.Options();
50 |
51 | // downsizing image as it throws OutOfMemory Exception for larger
52 | // images
53 | options.inSampleSize = sampleSize;
54 |
55 | return BitmapFactory.decodeFile(filePath, options);
56 | }
57 |
58 | /**
59 | * Checks whether device has camera or not. This method not necessary if
60 | * android:required="true" is used in manifest file
61 | */
62 | public static boolean isDeviceSupportCamera(Context context) {
63 | if (context.getPackageManager().hasSystemFeature(
64 | PackageManager.FEATURE_CAMERA)) {
65 | // this device has a camera
66 | return true;
67 | } else {
68 | // no camera on this device
69 | return false;
70 | }
71 | }
72 |
73 | /**
74 | * Open device app settings to allow user to enable permissions
75 | */
76 | public static void openSettings(Context context) {
77 | Intent intent = new Intent();
78 | intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
79 | intent.setData(Uri.fromParts("package", BuildConfig.APPLICATION_ID, null));
80 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
81 | context.startActivity(intent);
82 | }
83 |
84 | public static Uri getOutputMediaFileUri(Context context, File file) {
85 | return FileProvider.getUriForFile(context, context.getPackageName() + ".provider", file);
86 | }
87 |
88 | /**
89 | * Creates and returns the image or video file before opening the camera
90 | */
91 | public static File getOutputMediaFile(int type) {
92 |
93 | // External sdcard location
94 | File mediaStorageDir = new File(
95 | Environment
96 | .getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES),
97 | MainActivity.GALLERY_DIRECTORY_NAME);
98 |
99 | // Create the storage directory if it does not exist
100 | if (!mediaStorageDir.exists()) {
101 | if (!mediaStorageDir.mkdirs()) {
102 | Log.e(MainActivity.GALLERY_DIRECTORY_NAME, "Oops! Failed create "
103 | + MainActivity.GALLERY_DIRECTORY_NAME + " directory");
104 | return null;
105 | }
106 | }
107 |
108 | // Preparing media file naming convention
109 | // adds timestamp
110 | String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss",
111 | Locale.getDefault()).format(new Date());
112 | File mediaFile;
113 | if (type == MainActivity.MEDIA_TYPE_IMAGE) {
114 | mediaFile = new File(mediaStorageDir.getPath() + File.separator
115 | + "IMG_" + timeStamp + "." + MainActivity.IMAGE_EXTENSION);
116 | } else if (type == MainActivity.MEDIA_TYPE_VIDEO) {
117 | mediaFile = new File(mediaStorageDir.getPath() + File.separator
118 | + "VID_" + timeStamp + "." + MainActivity.VIDEO_EXTENSION);
119 | } else {
120 | return null;
121 | }
122 |
123 | return mediaFile;
124 | }
125 |
126 | }
127 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
--------------------------------------------------------------------------------
/app/src/main/java/info/androidhive/androidcamera/MainActivity.java:
--------------------------------------------------------------------------------
1 | package info.androidhive.androidcamera;
2 |
3 | import android.Manifest;
4 | import android.content.DialogInterface;
5 | import android.content.Intent;
6 | import android.graphics.Bitmap;
7 | import android.net.Uri;
8 | import android.os.Bundle;
9 | import android.provider.MediaStore;
10 | import android.support.v7.app.AlertDialog;
11 | import android.support.v7.app.AppCompatActivity;
12 | import android.support.v7.widget.Toolbar;
13 | import android.text.TextUtils;
14 | import android.view.View;
15 | import android.widget.Button;
16 | import android.widget.ImageView;
17 | import android.widget.TextView;
18 | import android.widget.Toast;
19 | import android.widget.VideoView;
20 |
21 | import com.karumi.dexter.Dexter;
22 | import com.karumi.dexter.MultiplePermissionsReport;
23 | import com.karumi.dexter.PermissionToken;
24 | import com.karumi.dexter.listener.PermissionRequest;
25 | import com.karumi.dexter.listener.multi.MultiplePermissionsListener;
26 |
27 | import java.io.File;
28 | import java.util.List;
29 |
30 | public class MainActivity extends AppCompatActivity {
31 |
32 | // Activity request codes
33 | private static final int CAMERA_CAPTURE_IMAGE_REQUEST_CODE = 100;
34 | private static final int CAMERA_CAPTURE_VIDEO_REQUEST_CODE = 200;
35 |
36 | // key to store image path in savedInstance state
37 | public static final String KEY_IMAGE_STORAGE_PATH = "image_path";
38 |
39 | public static final int MEDIA_TYPE_IMAGE = 1;
40 | public static final int MEDIA_TYPE_VIDEO = 2;
41 |
42 | // Bitmap sampling size
43 | public static final int BITMAP_SAMPLE_SIZE = 8;
44 |
45 | // Gallery directory name to store the images or videos
46 | public static final String GALLERY_DIRECTORY_NAME = "Hello Camera";
47 |
48 | // Image and Video file extensions
49 | public static final String IMAGE_EXTENSION = "jpg";
50 | public static final String VIDEO_EXTENSION = "mp4";
51 |
52 | private static String imageStoragePath;
53 |
54 | private TextView txtDescription;
55 | private ImageView imgPreview;
56 | private VideoView videoPreview;
57 | private Button btnCapturePicture, btnRecordVideo;
58 |
59 |
60 | @Override
61 | protected void onCreate(Bundle savedInstanceState) {
62 | super.onCreate(savedInstanceState);
63 | setContentView(R.layout.activity_main);
64 | Toolbar toolbar = findViewById(R.id.toolbar);
65 | setSupportActionBar(toolbar);
66 |
67 | // Checking availability of the camera
68 | if (!CameraUtils.isDeviceSupportCamera(getApplicationContext())) {
69 | Toast.makeText(getApplicationContext(),
70 | "Sorry! Your device doesn't support camera",
71 | Toast.LENGTH_LONG).show();
72 | // will close the app if the device doesn't have camera
73 | finish();
74 | }
75 |
76 | txtDescription = findViewById(R.id.txt_desc);
77 | imgPreview = findViewById(R.id.imgPreview);
78 | videoPreview = findViewById(R.id.videoPreview);
79 | btnCapturePicture = findViewById(R.id.btnCapturePicture);
80 | btnRecordVideo = findViewById(R.id.btnRecordVideo);
81 |
82 | /**
83 | * Capture image on button click
84 | */
85 | btnCapturePicture.setOnClickListener(new View.OnClickListener() {
86 |
87 | @Override
88 | public void onClick(View v) {
89 | if (CameraUtils.checkPermissions(getApplicationContext())) {
90 | captureImage();
91 | } else {
92 | requestCameraPermission(MEDIA_TYPE_IMAGE);
93 | }
94 | }
95 | });
96 |
97 | /**
98 | * Record video on button click
99 | */
100 | btnRecordVideo.setOnClickListener(new View.OnClickListener() {
101 |
102 | @Override
103 | public void onClick(View v) {
104 | if (CameraUtils.checkPermissions(getApplicationContext())) {
105 | captureVideo();
106 | } else {
107 | requestCameraPermission(MEDIA_TYPE_VIDEO);
108 | }
109 | }
110 | });
111 |
112 | // restoring storage image path from saved instance state
113 | // otherwise the path will be null on device rotation
114 | restoreFromBundle(savedInstanceState);
115 | }
116 |
117 | /**
118 | * Restoring store image path from saved instance state
119 | */
120 | private void restoreFromBundle(Bundle savedInstanceState) {
121 | if (savedInstanceState != null) {
122 | if (savedInstanceState.containsKey(KEY_IMAGE_STORAGE_PATH)) {
123 | imageStoragePath = savedInstanceState.getString(KEY_IMAGE_STORAGE_PATH);
124 | if (!TextUtils.isEmpty(imageStoragePath)) {
125 | if (imageStoragePath.substring(imageStoragePath.lastIndexOf(".")).equals("." + IMAGE_EXTENSION)) {
126 | previewCapturedImage();
127 | } else if (imageStoragePath.substring(imageStoragePath.lastIndexOf(".")).equals("." + VIDEO_EXTENSION)) {
128 | previewVideo();
129 | }
130 | }
131 | }
132 | }
133 | }
134 |
135 | /**
136 | * Requesting permissions using Dexter library
137 | */
138 | private void requestCameraPermission(final int type) {
139 | Dexter.withActivity(this)
140 | .withPermissions(Manifest.permission.CAMERA,
141 | Manifest.permission.WRITE_EXTERNAL_STORAGE,
142 | Manifest.permission.RECORD_AUDIO)
143 | .withListener(new MultiplePermissionsListener() {
144 | @Override
145 | public void onPermissionsChecked(MultiplePermissionsReport report) {
146 | if (report.areAllPermissionsGranted()) {
147 |
148 | if (type == MEDIA_TYPE_IMAGE) {
149 | // capture picture
150 | captureImage();
151 | } else {
152 | captureVideo();
153 | }
154 |
155 | } else if (report.isAnyPermissionPermanentlyDenied()) {
156 | showPermissionsAlert();
157 | }
158 | }
159 |
160 | @Override
161 | public void onPermissionRationaleShouldBeShown(List permissions, PermissionToken token) {
162 | token.continuePermissionRequest();
163 | }
164 | }).check();
165 | }
166 |
167 |
168 | /**
169 | * Capturing Camera Image will launch camera app requested image capture
170 | */
171 | private void captureImage() {
172 | Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
173 |
174 | File file = CameraUtils.getOutputMediaFile(MEDIA_TYPE_IMAGE);
175 | if (file != null) {
176 | imageStoragePath = file.getAbsolutePath();
177 | }
178 |
179 | Uri fileUri = CameraUtils.getOutputMediaFileUri(getApplicationContext(), file);
180 |
181 | intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);
182 |
183 | // start the image capture Intent
184 | startActivityForResult(intent, CAMERA_CAPTURE_IMAGE_REQUEST_CODE);
185 | }
186 |
187 | /**
188 | * Saving stored image path to saved instance state
189 | */
190 | @Override
191 | protected void onSaveInstanceState(Bundle outState) {
192 | super.onSaveInstanceState(outState);
193 |
194 | // save file url in bundle as it will be null on screen orientation
195 | // changes
196 | outState.putString(KEY_IMAGE_STORAGE_PATH, imageStoragePath);
197 | }
198 |
199 | /**
200 | * Restoring image path from saved instance state
201 | */
202 | @Override
203 | protected void onRestoreInstanceState(Bundle savedInstanceState) {
204 | super.onRestoreInstanceState(savedInstanceState);
205 |
206 | // get the file url
207 | imageStoragePath = savedInstanceState.getString(KEY_IMAGE_STORAGE_PATH);
208 | }
209 |
210 | /**
211 | * Launching camera app to record video
212 | */
213 | private void captureVideo() {
214 | Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
215 |
216 | File file = CameraUtils.getOutputMediaFile(MEDIA_TYPE_VIDEO);
217 | if (file != null) {
218 | imageStoragePath = file.getAbsolutePath();
219 | }
220 |
221 | Uri fileUri = CameraUtils.getOutputMediaFileUri(getApplicationContext(), file);
222 |
223 | // set video quality
224 | intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
225 |
226 | intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // set the image file
227 |
228 | // start the video capture Intent
229 | startActivityForResult(intent, CAMERA_CAPTURE_VIDEO_REQUEST_CODE);
230 | }
231 |
232 | /**
233 | * Activity result method will be called after closing the camera
234 | */
235 | @Override
236 | protected void onActivityResult(int requestCode, int resultCode, Intent data) {
237 | // if the result is capturing Image
238 | if (requestCode == CAMERA_CAPTURE_IMAGE_REQUEST_CODE) {
239 | if (resultCode == RESULT_OK) {
240 | // Refreshing the gallery
241 | CameraUtils.refreshGallery(getApplicationContext(), imageStoragePath);
242 |
243 | // successfully captured the image
244 | // display it in image view
245 | previewCapturedImage();
246 | } else if (resultCode == RESULT_CANCELED) {
247 | // user cancelled Image capture
248 | Toast.makeText(getApplicationContext(),
249 | "User cancelled image capture", Toast.LENGTH_SHORT)
250 | .show();
251 | } else {
252 | // failed to capture image
253 | Toast.makeText(getApplicationContext(),
254 | "Sorry! Failed to capture image", Toast.LENGTH_SHORT)
255 | .show();
256 | }
257 | } else if (requestCode == CAMERA_CAPTURE_VIDEO_REQUEST_CODE) {
258 | if (resultCode == RESULT_OK) {
259 | // Refreshing the gallery
260 | CameraUtils.refreshGallery(getApplicationContext(), imageStoragePath);
261 |
262 | // video successfully recorded
263 | // preview the recorded video
264 | previewVideo();
265 | } else if (resultCode == RESULT_CANCELED) {
266 | // user cancelled recording
267 | Toast.makeText(getApplicationContext(),
268 | "User cancelled video recording", Toast.LENGTH_SHORT)
269 | .show();
270 | } else {
271 | // failed to record video
272 | Toast.makeText(getApplicationContext(),
273 | "Sorry! Failed to record video", Toast.LENGTH_SHORT)
274 | .show();
275 | }
276 | }
277 | }
278 |
279 | /**
280 | * Display image from gallery
281 | */
282 | private void previewCapturedImage() {
283 | try {
284 | // hide video preview
285 | txtDescription.setVisibility(View.GONE);
286 | videoPreview.setVisibility(View.GONE);
287 |
288 | imgPreview.setVisibility(View.VISIBLE);
289 |
290 | Bitmap bitmap = CameraUtils.optimizeBitmap(BITMAP_SAMPLE_SIZE, imageStoragePath);
291 |
292 | imgPreview.setImageBitmap(bitmap);
293 |
294 | } catch (NullPointerException e) {
295 | e.printStackTrace();
296 | }
297 | }
298 |
299 | /**
300 | * Displaying video in VideoView
301 | */
302 | private void previewVideo() {
303 | try {
304 | // hide image preview
305 | txtDescription.setVisibility(View.GONE);
306 | imgPreview.setVisibility(View.GONE);
307 |
308 | videoPreview.setVisibility(View.VISIBLE);
309 | videoPreview.setVideoPath(imageStoragePath);
310 | // start playing
311 | videoPreview.start();
312 | } catch (Exception e) {
313 | e.printStackTrace();
314 | }
315 | }
316 |
317 | /**
318 | * Alert dialog to navigate to app settings
319 | * to enable necessary permissions
320 | */
321 | private void showPermissionsAlert() {
322 | AlertDialog.Builder builder = new AlertDialog.Builder(this);
323 | builder.setTitle("Permissions required!")
324 | .setMessage("Camera needs few permissions to work properly. Grant them in settings.")
325 | .setPositiveButton("GOTO SETTINGS", new DialogInterface.OnClickListener() {
326 | public void onClick(DialogInterface dialog, int which) {
327 | CameraUtils.openSettings(MainActivity.this);
328 | }
329 | })
330 | .setNegativeButton("CANCEL", new DialogInterface.OnClickListener() {
331 | public void onClick(DialogInterface dialog, int which) {
332 |
333 | }
334 | }).show();
335 | }
336 | }
337 |
--------------------------------------------------------------------------------