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);
           }
  }
              
            }  
  
 
}



8 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. Inspiring writings and I greatly admired what you have to say , I hope you continue to provide new ideas for us all and greetings success always for you..Keep update more information..

    rpa Training in Chennai

    rpa Training in bangalore

    rpa Training in pune

    blueprism Training in Chennai

    blueprism Training in bangalore

    blueprism Training in pune

    rpa online training

    ReplyDelete
  4. 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
  5. 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