- 论坛徽章:
- 0
|
Android开发返回拍摄的图片
第一步
Java代码- 1.try {
- 2. Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
- 3. startActivityForResult(intent, 0);
- 4.
- 5.} catch (ActivityNotFoundException e) {
- 6. // Do nothing for now
- 7.}
- try {
- Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
- startActivityForResult(intent, 0);
- } catch (ActivityNotFoundException e) {
- // Do nothing for now
- }
复制代码 第一步
Java代码- 1.@Override
- 2. protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- 3. try {
- 4. if (requestCode != 0) {
- 5. return;
- 6. }
- 7. super.onActivityResult(requestCode, resultCode, data);
- 8. Bundle extras = data.getExtras();
- 9. Bitmap b = (Bitmap) extras.get("data");
- 10. //
- 11.
- 12. //
- 13. ImageView a = (ImageView)findViewById(R.id.imageView1);
- 14. a.setImageBitmap(b);
- 15. //
- 16. /*
- 17. * 得到图片对图片处理...
- 18. */
- 19. } catch (Exception e) {
- 20. // TODO: handle exception
- 21. System.out.println(e.getMessage());
- 22. }
- 23. }
复制代码 |
|