View

Wednesday 13 April 2011

Click the Button and open Image Gallery


import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;

public class tuesdayAppli extends Activity {
    private static final int SELECT_PICTURE = 1;
/** Called when the activity is first created. */
Button button1;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
      
        button1=(Button)findViewById(R.id.button1);
        button1.setOnClickListener(new OnClickListener() {

@Override

public void onClick(View v) {
// TODO Auto-generated method stub
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent,
"Select Picture"), SELECT_PICTURE);
}
});
    }
        protected void onActivityResult(int requestCode, int resultCode, Intent data) {
          super.onActivityResult(requestCode, resultCode, data);
          switch(requestCode) {
          case SELECT_PICTURE: // our request code
           if(resultCode == Activity.RESULT_OK)
           { // result was ok
           Uri selectedImage = data.getData();
           Intent i = new Intent(getApplicationContext(),ImageView.class);

               // ----------------- Problem Area -----------------
               // I would like to send the filename to the Intent object, and send it over.
               // However, the selectedImage.toString() method will return a
               // "content://" string instead of a file location.  How do I get a file
               // location from that URI object?
               i.putExtra("PICTURE_LOCATION", selectedImage.toString());

               // Start the activity outlined with the Intent above:
               startActivity(i);
           }
  }
              
            }  
  
 
}



17 comments:

  1. hi saga,

    could u pls give me ur email address??

    is this image gallery taking images from net??

    where did u specify the url path??

    thanks

    ReplyDelete
  2. I simply want to say I’m very new to blogs and actually loved you’re blog site. Almost certainly I’m going to bookmark your blog post . You absolutely come with great well written articles. Thanks a lot for sharing your blog.
    android development course fees in chennai | android app development training in chennai|Android Training institute in chennai with placement

    ReplyDelete
  3. UiPath Training in Bangalore by myTectra is one the best UiPath Training. myTectra is the market leader in providing Robotic Process Automation on UiPath
    ui path training in bangalore

    ReplyDelete
  4. I am really happy with your blog because your article is very unique and powerful for new reader.
    Click here:
    selenium training in chennai
    selenium training in bangalore
    selenium training in Pune
    selenium training in pune
    Selenium Online Training



    https://sandblogaspnet.blogspot.com/2009/07/working-with-modal-popup-extender.html

    ReplyDelete
  5. Hi,
    Best article, very useful and well explanation. Your post is extremely incredible.Good job & thank you very much for the new information, i learned something new. Very well written. It was sooo good to read and usefull to improve knowledge. Who want to learn this information most helpful. One who wanted to learn this technology IT employees will always suggest you take Best Training institutes for python course in BTM Layout

    ReplyDelete
  6. Really i appreciate the effort you made to share the knowledge. The topic here i found was really effective...

    Become an Expert In SAP BASIS Training! The most trusted and trending Programming Language. Learn from experienced Trainers and get the knowledge to crack a coding interview, @Softgen Infotech Located in BTM Layout.

    ReplyDelete
  7. Very useful post,thanks for sharing.Very clear and understandable content.ElasticSearch is a search engine based on Lucene Library
    elasticsearch training institute in btm layout

    ReplyDelete
  8. I love the blog. Great post. It is very true, people must learn how to learn before they can learn. lol i know it sounds funny but its very true. . .lovely page.
    Ai & Artificial Intelligence Course in Chennai
    PHP Training in Chennai
    Ethical Hacking Course in Chennai Blue Prism Training in Chennai
    UiPath Training in Chennai

    ReplyDelete
  9. I appreciate your efforts because it conveys the message of what you are trying to say. It's a great skill to make even the person who doesn't know about the subject could able to understand the subject . Your blogs are understandable and also elaborately described. I hope to read more and more interesting articles from your blog
    web designing training in chennai

    web designing training in tambaram

    digital marketing training in chennai

    digital marketing training in tambaram

    rpa training in chennai

    rpa training in tambaram

    tally training in chennai

    tally training in tambaram

    ReplyDelete