Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' of github.com:nRike/GDG-Hackup-AndroidTitlan

  • Loading branch information...
commit 86822a880991b057d83ba3abef1f15b550b35036 2 parents 1aaa0b3 + 1014ec8
@fabianhjr fabianhjr authored
View
4 .settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,4 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.source=1.6
View
6 AndroidManifest.xml
@@ -4,6 +4,12 @@
android:versionCode="1"
android:versionName="1.0" >
+ <!-- Permisos para utilizar la camara -->
+ <uses-permission android:name="android.permission.CAMERA" />
+
+ <uses-feature android:name="android.hardware.camara" />
+ <uses-feature android:name="android.hardware.autofocus" />
+
<uses-sdk
android:minSdkVersion="4"
android:targetSdkVersion="17" />
View
2  project.properties
@@ -11,4 +11,4 @@
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
# Project target.
-target=android-17
+target=android-14
View
16 res/layout/activity_home.xml
@@ -4,11 +4,21 @@
android:layout_height="match_parent"
tools:context=".HomeActivity" >
- <TextView
+ <Button
+ android:id="@+id/tomar_foto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
- android:layout_centerVertical="true"
- android:text="@string/hello_world" />
+ android:text="Foto" />
+
+ <ImageView
+ android:id="@+id/imagen_capturada"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_below="@+id/tomar_foto"
+ android:layout_centerHorizontal="true"
+ android:layout_marginTop="130dp"
+ android:src="@drawable/ic_launcher" />
</RelativeLayout>
View
68 src/mx/androidtitlan/GDGHackup/HomeActivity.java
@@ -1,22 +1,86 @@
package mx.androidtitlan.GDGHackup;
-import android.os.Bundle;
import android.app.Activity;
+import android.app.AlertDialog;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.graphics.Bitmap;
+import android.os.Bundle;
+import android.provider.MediaStore;
+import android.util.Log;
import android.view.Menu;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.Button;
+import android.widget.ImageView;
public class HomeActivity extends Activity {
+ private Button button;
+ private final int flag = 1;
+ private ImageView imageView;
+ private Bitmap imagenCapturada;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
+
+ this.button = (Button) findViewById(R.id.tomar_foto);
+ imageView = (ImageView) findViewById(R.id.imagen_capturada);
+
+ button.setOnClickListener(new OnClickListener() {
+
+ @Override
+ public void onClick(View arg0) {
+ tomarFoto(flag);
+ }
+ });
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
- // Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_home, menu);
return true;
}
+ private void tomarFoto(int flag) {
+ Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
+ startActivityForResult(intent, flag);
+ }
+
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+
+ AlertDialog dialog;
+
+ if (resultCode == RESULT_CANCELED) {
+
+ dialog = crearDialogo("FOTO", "Fallo al tomar la foto", "OK");
+
+ } else {
+ imagenCapturada = (Bitmap) data.getExtras().get("data");
+ dialog = crearDialogo("FOTO", "Éxito al tomar la foto", "OK");
+
+ }
+ dialog.show();
+ }
+
+ private AlertDialog crearDialogo(String title, String msg, String buttonText) {
+ AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
+ AlertDialog msgDialog = dialogBuilder.create();
+ msgDialog.setTitle(title);
+ msgDialog.setMessage(msg);
+ msgDialog.setButton(buttonText, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int idx) {
+ dialog.dismiss();
+ imageView.setImageBitmap(imagenCapturada);
+
+ }
+ });
+
+ return msgDialog;
+ }
+
}
Please sign in to comment.
Something went wrong with that request. Please try again.