Click here to Skip to main content
15,880,608 members
Home / Discussions / Android
   

Android

 
AnswerRe: Panorama viewer with gyro support - Html5 Pin
Richard MacCutchan9-Jul-15 22:05
mveRichard MacCutchan9-Jul-15 22:05 
GeneralRe: Panorama viewer with gyro support - Html5 Pin
martin prochazka 197912-Jul-15 3:42
martin prochazka 197912-Jul-15 3:42 
QuestionUploading Video to server through SOAP webservice using Android Pin
Member 116050787-Jul-15 0:02
Member 116050787-Jul-15 0:02 
AnswerRe: Uploading Video to server through SOAP webservice using Android Pin
Richard MacCutchan7-Jul-15 1:58
mveRichard MacCutchan7-Jul-15 1:58 
QuestionHow to implement unlimited number of text views Pin
jasonalien6-Jul-15 21:46
jasonalien6-Jul-15 21:46 
AnswerRe: How to implement unlimited number of text views Pin
Richard MacCutchan6-Jul-15 22:05
mveRichard MacCutchan6-Jul-15 22:05 
QuestionWebsocket timeout via NGINX only in a 3G hotspot Pin
Dickens A S2-Jul-15 16:53
professionalDickens A S2-Jul-15 16:53 
QuestionGalery camera android Pin
Ibrahim.elh2-Jul-15 2:42
Ibrahim.elh2-Jul-15 2:42 
Hello,
I am a beginner in android and I created a project that provides access to a camera with another activity gallery.
I would like to view pictures taken by the camera in the gallery.
here is my code of activity gallery:
Java
public class gallerie extends ActionBarActivity {
    Integer[] imageIDs = {
            R.drawable.a,
            R.drawable.b
    };
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_gallerie);
        Gallery gallery = (Gallery) findViewById(R.id.gallery1);
        gallery.setAdapter(new ImageAdapter(this));
        gallery.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            public void onItemClick(AdapterView<?> parent, View v, int position,long id)
            {
                Toast.makeText(getBaseContext(), "pic" + (position + 1) + " selected",
                        Toast.LENGTH_SHORT).show();
                // display the images selected
                ImageView imageView = (ImageView) findViewById(R.id.image1);
                imageView.setImageResource(imageIDs[position]);
            }
        });
    }
 
    public class ImageAdapter extends BaseAdapter {
        private Context context;
        private int itemBackground;
        public ImageAdapter(Context c)
        {
            context = c;
            // sets a grey background; wraps around the images
            TypedArray a =obtainStyledAttributes(R.styleable.MyGallery);
            itemBackground = a.getResourceId(R.styleable.MyGallery_android_galleryItemBackground, 0);
            a.recycle();
        }
        // returns the number of images
        public int getCount() {
            return imageIDs.length;
        }
        // returns the ID of an item
        public Object getItem(int position) {
            return position;
        }
        // returns the ID of an item
        public long getItemId(int position) {
            return position;
        }
        // returns an ImageView view
        public View getView(int position, View convertView, ViewGroup parent) {
            ImageView imageView = new ImageView(context);
            imageView.setImageResource(imageIDs[position]);
            imageView.setLayoutParams(new Gallery.LayoutParams(400, 400));
            imageView.setBackgroundResource(itemBackground);
            return imageView;
        }
    }
 
 
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_gallerie, menu);
        return true;
    }
 
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
 
        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }
 
        return super.onOptionsItemSelected(item);
    }
}

Code the class that contains the camera:
Java
private GoogleMap mMap; // Might be null if Google Play services APK is not available.
    private LatLng myPosition;
    int TAKE_PHOTO_CODE = 0;
    public static int count=0;
 private void setCamera(Bundle savedInstanceState){
 
//here,we are making a folder named picFolder to store pics taken by the camera using this application
        final String dir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES) + "/picFolder/";
        File newdir = new File(dir);
        newdir.mkdirs();
 
        Button capture = (Button) findViewById(R.id.btn_photo);
        capture.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
 
                // here,counter will be incremented each time,and the picture taken by camera will be stored as 1.jpg,2.jpg and likewise.
                count++;
                String file = dir + count + ".jpg";
                File newfile = new File(file);
                try {
                    newfile.createNewFile();
                } catch (IOException e) {
                }
 
                Uri outputFileUri = Uri.fromFile(newfile);
 
                Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
 
                startActivityForResult(cameraIntent, TAKE_PHOTO_CODE);
            }
        });
    }
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
 
        if (requestCode == TAKE_PHOTO_CODE && resultCode == RESULT_OK) {
            Log.d("CameraDemo", "Pic saved");
 
 
        }
    }

SuggestionRe: Galery camera android Pin
David Crow2-Jul-15 4:55
David Crow2-Jul-15 4:55 
Questionthe find registered source SIM Tool Kit ? Pin
Member 245846720-Jun-15 13:28
Member 245846720-Jun-15 13:28 
AnswerRe: the find registered source SIM Tool Kit ? Pin
Richard MacCutchan20-Jun-15 21:20
mveRichard MacCutchan20-Jun-15 21:20 
GeneralRe: the find registered source SIM Tool Kit ? Pin
Member 245846721-Jun-15 3:20
Member 245846721-Jun-15 3:20 
Question"Search your Doctor " Pin
Member 1084090620-Jun-15 10:54
Member 1084090620-Jun-15 10:54 
QuestionRe: "Search your Doctor " Pin
David Crow20-Jun-15 17:02
David Crow20-Jun-15 17:02 
QuestionHow can I record local media stream. Pin
Member 1161266218-Jun-15 22:00
Member 1161266218-Jun-15 22:00 
Questionhow to retrieve edit box data in Visual studio 2008 MFC program Pin
sreedhar.jakkani17-Jun-15 22:39
sreedhar.jakkani17-Jun-15 22:39 
SuggestionRe: how to retrieve edit box data in Visual studio 2008 MFC program Pin
Richard MacCutchan18-Jun-15 1:03
mveRichard MacCutchan18-Jun-15 1:03 
QuestionConnect more than one android device by coding Pin
Member 117540029-Jun-15 10:42
Member 117540029-Jun-15 10:42 
SuggestionRe: Connect more than one android device by coding Pin
Richard MacCutchan9-Jun-15 21:12
mveRichard MacCutchan9-Jun-15 21:12 
Questionandroid parsing Pin
Member 117527499-Jun-15 1:26
Member 117527499-Jun-15 1:26 
AnswerRe: android parsing Pin
Richard MacCutchan9-Jun-15 3:42
mveRichard MacCutchan9-Jun-15 3:42 
QuestionRe: android parsing Pin
David Crow9-Jun-15 5:41
David Crow9-Jun-15 5:41 
QuestionAndroid Application in TAB HOST TabActivity can't Start Pin
Member 103287028-Jun-15 7:16
Member 103287028-Jun-15 7:16 
QuestionRe: Android Application in TAB HOST TabActivity can't Start Pin
David Crow8-Jun-15 9:17
David Crow8-Jun-15 9:17 
AnswerRe: Android Application in TAB HOST TabActivity can't Start Pin
Dadecki18-Jun-15 0:10
Dadecki18-Jun-15 0:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.