This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.company; | |
| //Name of the class | |
| public class Cat { | |
| //Private variables | |
| private int age; | |
| private String name; | |
| //Private constant | |
| private final boolean isMale; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private static final int GALLERY_REQUEST_CODE = 100; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Intent intent = new Intent(); | |
| intent.setType("image/*"); | |
| intent.setAction(Intent.ACTION_GET_CONTENT); | |
| startActivityForResult(Intent.createChooser(intent, "Select Picture"), GALLERY_REQUEST_CODE); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| protected void onActivityResult(int requestCode, int resultCode, Intent data) { | |
| super.onActivityResult(requestCode, resultCode, data); | |
| if (resultCode == RESULT_OK && requestCode == GALLERY_REQUEST_CODE) { | |
| try { | |
| Uri selectedImage = data.getData(); | |
| InputStream imageStream = getContentResolver().openInputStream(selectedImage); | |
| selectedImageView.setImageBitmap(BitmapFactory.decodeStream(imageStream)); | |
| } catch (IOException exception) { | |
| exception.printStackTrace(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private static final int CAMERA_REQUEST_CODE = 200; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); | |
| if (takePictureIntent.resolveActivity(getPackageManager()) != null) { | |
| startActivityForResult(takePictureIntent, CAMERA_REQUEST_CODE); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if (requestCode == CAMERA_REQUEST_CODE && resultCode == RESULT_OK) { | |
| Bundle extras = data.getExtras(); | |
| Bitmap imageBitmap = (Bitmap) extras.get("data"); | |
| selectedImageView.setImageBitmap(imageBitmap); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private Bitmap image; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public Memory(String title, Bitmap image) { | |
| this.title = title; | |
| this.image = image; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private static final String SQL_CREATE_ENTRIES = | |
| "CREATE TABLE " + MemoryContract.MemoryEntry.TABLE_NAME + " (" + | |
| MemoryContract.MemoryEntry._ID + INTEGER_TYPE + " PRIMARY KEY" + COMMA_SEP + | |
| MemoryContract.MemoryEntry.COLUMN_IMAGE + TEXT_TYPE + COMMA_SEP + | |
| MemoryContract.MemoryEntry.COLUMN_TITLE + TEXT_TYPE + " )"; |
OlderNewer