[Android实例] 调用相册和拍…
来源:互联网 发布:宁夏干部网络培训官网 编辑:程序博客网 时间:2024/05/06 19:27
package com.samsung.android.activity;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import android.app.Activity;
import android.content.ContentResolver;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.provider.MediaStore;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.PopupWindow;
public class ImagePageActivity extends Activity implementsOnClickListener {
private ImageButton addbtn;
private ImageButton back_btn;
private PopupWindow popupWindow;
private Button openPhoto, camera,close;
private ImageView imageView;
private int REQUEST_CAMERA =1;
@Override
protected void onCreate(BundlesavedInstanceState) {
// TODO Auto-generated methodstub
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.photopage);
LayoutInflater inflater =LayoutInflater.from(this);
View layout =inflater.inflate(R.layout.popupmenu, null);
popupWindow = newPopupWindow(layout, 200, 200);
addbtn = (ImageButton)findViewById(R.id.photopage_addphoto_btn);
addbtn.setOnClickListener(this);
back_btn = (ImageButton)findViewById(R.id.photopage_backmain_btn);
back_btn.setOnClickListener(this);
close = (Button)layout.findViewById(R.id.closepop);
close.setOnClickListener(this);
camera = (Button)layout.findViewById(R.id.camera);
camera.setOnClickListener(this);
openPhoto = (Button)layout.findViewById(R.id.openPhoto);
openPhoto.setOnClickListener(this);
imageView =(ImageView)findViewById(R.id.imageView1);
}
@Override
public void onClick(View v) {
// TODO Auto-generated methodstub
switch (v.getId()){
case R.id.closepop:
popupWindow.dismiss();
popupWindow.setFocusable(false);
break;