Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Android
Search Coderanch
Advance search
Google search
Register / Login
Win a copy of
Eclipse Collections Categorically: Level up your programming game
this week in the
Open Source Projects
forum!
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Tim Cooke
paul wheaton
Ron McLeod
Jeanne Boyarsky
Sheriffs:
Paul Clapham
Saloon Keepers:
Tim Holloway
Roland Mueller
Bartenders:
Forum:
Android
cannot display image captured
Kasun Wixkramanayake
Ranch Hand
Posts: 74
posted 11 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
public class MainActivity extends Activity { // private static final int CAMERA_REQUEST = 1888; private ImageView imageView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); this.imageView = (ImageView) this.findViewById(R.id.imageView1); Button photoButton = (Button) this.findViewById(R.id.button1); photoButton .setOnClickListener(oclBtnOk); } OnClickListener oclBtnOk = new OnClickListener() { @Override public void onClick(View v) { //Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); // startActivityForResult(cameraIntent, 1); Intent i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); File out = Environment.getExternalStorageDirectory(); out = new File(out, "kp.jpg"); i.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(out)); startActivityForResult(i, 1); } }; protected void onActivityResult(int requestCode, int resultCode, Intent data) { // if (requestCode == CAMERA_REQUEST && resultCode == RESULT_OK) // { if (requestCode==1 && resultCode == RESULT_OK){ try{//Toast.makeText(getApplicationContext(),"yes", Toast.LENGTH_LONG).show(); Bitmap photo = (Bitmap) data.getExtras().get("data"); imageView.setImageBitmap(photo);}catch(Exception e){ e.printStackTrace(); } // MediaStore.Images.Media.insertImage(getContentResolver(), photo, //null, null); // ByteArrayOutputStream baos = new ByteArrayOutputStream(); // photo.compress(Bitmap.CompressFormat.JPEG, 1000, baos); // byte[] b = baos.toByteArray(); } } }
when i run above code picture is saved in the memory card .but it cannnot be dispalyed on the image view as a thumbenail
Opportunity is missed by most people because it is dressed in overalls and looks like work - Edison. Tiny ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Help to insert/retreive image from database
how to create sdcard and mount on the emulator
How to change contacts thumbnail using ContentResolver?
Android socket file transfer between two android phones
java code for speech to text
More...