一个Android程序,想实现调用系统相机拍照,然后存储照片的功能,代码如下。 15
第四行publicvoidonActivityResult(intrequestCode,intresultCode,Intentdata)这一行报错,Multiplem...
第四行public void onActivityResult(int requestCode, int resultCode, Intent data)这一行报错,
Multiple markers at this line
- Syntax error, insert ";" to complete
LocalVariableDeclarationStatement
- Syntax error on token "(", ; expected
- void is an invalid type for the variable onAc
谁能帮帮我呢?这是怎么回事?
{
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent, 1);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data)
{
{ super.onActivityResult(requestCode, resultCode, data);}
if(requestCode == CAMERA && resultCode == Activity.RESULT_OK && null != data)
{
String sdState=Environment.getExternalStorageState();
if(!sdState.equals(Environment.MEDIA_MOUNTED))
{
GameLog.log(Tag, "sd card unmount");
return;
}
new DateFormat();
String name= DateFormat.format("yyyyMMdd_hhmmss", Calendar.getInstance(Locale.CHINA))+".jpg";
Bundle bundle = data.getExtras();
//获取相机返回的数据,并转换为图片格式
Bitmap bitmap = (Bitmap)bundle.get("data");
FileOutputStream fout = null;
File file = new File("/sdcard/pintu/");
file.mkdirs();
String filename=file.getPath()+name;
try
{
fout = new FileOutputStream(filename);
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fout);
}
catch (FileNotFoundException e)
{
e.printStackTrace();
}
finally
{
try
{
fout.flush();
fout.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
//显示图片
}
} 展开
Multiple markers at this line
- Syntax error, insert ";" to complete
LocalVariableDeclarationStatement
- Syntax error on token "(", ; expected
- void is an invalid type for the variable onAc
谁能帮帮我呢?这是怎么回事?
{
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent, 1);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data)
{
{ super.onActivityResult(requestCode, resultCode, data);}
if(requestCode == CAMERA && resultCode == Activity.RESULT_OK && null != data)
{
String sdState=Environment.getExternalStorageState();
if(!sdState.equals(Environment.MEDIA_MOUNTED))
{
GameLog.log(Tag, "sd card unmount");
return;
}
new DateFormat();
String name= DateFormat.format("yyyyMMdd_hhmmss", Calendar.getInstance(Locale.CHINA))+".jpg";
Bundle bundle = data.getExtras();
//获取相机返回的数据,并转换为图片格式
Bitmap bitmap = (Bitmap)bundle.get("data");
FileOutputStream fout = null;
File file = new File("/sdcard/pintu/");
file.mkdirs();
String filename=file.getPath()+name;
try
{
fout = new FileOutputStream(filename);
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fout);
}
catch (FileNotFoundException e)
{
e.printStackTrace();
}
finally
{
try
{
fout.flush();
fout.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
//显示图片
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询