create Activity add this code :
package com.zoomimage;
import java.io.File;
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;
import android.widget.Toast;
public class ZoomimageActivity extends Activity {
private ImageView imagev;
private Uri uri_img;
private Button btnZ;
private String mimetype;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
imagev = (ImageView) findViewById(R.id.imageView1);
// imagev.setImageUri(Uri.fromFile(new File("/sdcard/test.jpg")));
// imagev.setImageUri(Uri.parse(new File("/sdcard/cats.jpg").toString()));
uri_img = Uri.fromFile(new File("/sdcard/test.jpg"));
imagev.setImageURI(uri_img);
String extension = android.webkit.MimeTypeMap
.getFileExtensionFromUrl(uri_img.toString());
mimetype = android.webkit.MimeTypeMap.getSingleton()
.getMimeTypeFromExtension(extension);
btnZ = (Button) findViewById(R.id.button1);
btnZ.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Toast.makeText(ZoomimageActivity.this, "Please wait..",
Toast.LENGTH_SHORT).show();
Intent i = new Intent(android.content.Intent.ACTION_VIEW);
i.setDataAndType(uri_img, mimetype);
startActivity(i);
}
});
}
}
Enjoy Coding....
Please Give the proper description
ReplyDeletehow can I get image from data base, without put uri path?
ReplyDelete