问题描述
在我的$ C C图像$不在ImageView的从SD卡我已经检查了权限的manifest.xml打开。同样,如果我尝试使用静态的名字,那么它将被ImageView的,但不能动态显示,将其打开。
主要活动
私人OnClickListener参考OnCapture =新OnClickListener(){
@覆盖
公共无效的onClick(视图v){
字符串时间= mCamUtils.clickPicture();
nextActivity =新的意图(MainActivity.this,EffectActivity.class);
nextActivity.putExtra(ImageName,时间);
startActivity(nextActivity);
完();
}
};
EffectActivity
公共类EffectActivity延伸活动{
意图getActivity = NULL;
ImageView的形象= NULL;
@覆盖
公共无效的onCreate(包savedInstanceState){
super.onCreate(savedInstanceState);
的setContentView(R.layout.effectactivity);
getActivity = getIntent();
字符串名称= getActivity.getStringExtra(ImageName);
字符串路径= Environment.getExternalStorageDirectory()+/ GalaxyPhoto / GX_+姓名+.JPG;
Toast.makeText(getApplicationContext(),路径,Toast.LENGTH_LONG).show();
图像=(ImageView的)findViewById(R.id.imageView1);
文件f =新的文件(路径);
byte []的B =新的字节[(INT)f.length()];
如果(f.exists())
{
尝试
{
如果(f.exists())
{
的FileInputStream FF =新的FileInputStream(F);
ff.read(B);
位图G = BitmapFactory.de codeFILE(路径);
image.setImageBitmap(G);
ff.close();
}
其他
{
Toast.makeText(getApplicationContext(),ELSE,Toast.LENGTH_LONG).show();
}
}
赶上(例外五)
{
}
}
}
}
我试图打开我保存在此活动之前的形象和我赶上形象的名字在这里,但不显示图像。感谢您andvance ..
字符串路径= Environment.getExternalStorageDirectory()+/ GalaxyPhoto / GX_+姓名+.JPG;
在这一行尝试改变JPG到JPG。我想你的文件扩展名可能是小写字母,它可能会说f.exists假的。希望这将有助于。
In My Code The image is not open in ImageView from sdcard i already checked the permissions in 'manifest.xml'.Same if i try to open it using static name then it will showed by ImageView but not dynamically.
Main Activity
private OnClickListener OnCapture = new OnClickListener() {
@Override
public void onClick(View v) {
String time = mCamUtils.clickPicture();
nextActivity = new Intent(MainActivity.this,EffectActivity.class);
nextActivity.putExtra("ImageName", time);
startActivity(nextActivity);
finish();
}
};
EffectActivity
public class EffectActivity extends Activity {
Intent getActivity = null;
ImageView image = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.effectactivity);
getActivity = getIntent();
String name = getActivity.getStringExtra("ImageName");
String path = Environment.getExternalStorageDirectory()+"/GalaxyPhoto/GX_" +name+ ".JPG";
Toast.makeText(getApplicationContext(), path, Toast.LENGTH_LONG).show();
image = (ImageView) findViewById(R.id.imageView1);
File f = new File(path);
byte[] b = new byte[(int)f.length()];
if(f.exists())
{
try
{
if(f.exists())
{
FileInputStream ff = new FileInputStream(f);
ff.read(b);
Bitmap g = BitmapFactory.decodeFile(path);
image.setImageBitmap(g);
ff.close();
}
else
{
Toast.makeText(getApplicationContext(), "ELSE", Toast.LENGTH_LONG).show();
}
}
catch(Exception e)
{
}
}
}
}
I am trying to open image which i saved in before this activity and i catch the name of image here but that does not show the image.THANK YOU in andvance..
String path = Environment.getExternalStorageDirectory()+"/GalaxyPhoto/GX_" +name+ ".JPG";
In this line try changing "JPG" into "jpg".i think your file extension might be in lowercase letter and it might say f.exists false.Hope it will help.
这篇关于图像是不能在ImageView的动态地从SD卡展示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!