0
こんにちは人は、友人のための簡単な電子メールアプリケーションを作成..それは彼のビジネスの一部のために彼に情報を送信します。写真を添付する必要があることもあります。 IVEはカメラの開口部を解決し、コードどのように私はprogmaticly電子メールの一部として画像を送信するだろう
public class CameraDemoActivity extends Activity {
int TAKE_PHOTO_CODE = 0;
public static int count = 0;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Here, we are making a folder named picFolder to store
// pics taken by the camera using this application.
final String dir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES) + "/picFolder/";
File newdir = new File(dir);
newdir.mkdirs();
Button capture = (Button) findViewById(R.id.btnCapture);
capture.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// Here, the counter will be incremented each time, and the
// picture taken by camera will be stored as 1.jpg,2.jpg
// and likewise.
count++;
String file = dir+count+".jpg";
File newfile = new File(file);
try {
newfile.createNewFile();
}
catch (IOException e)
{
}
Uri outputFileUri = Uri.fromFile(newfile);
Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
startActivityForResult(cameraIntent, TAKE_PHOTO_CODE);
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == TAKE_PHOTO_CODE && resultCode == RESULT_OK) {
Log.d("CameraDemo", "Pic saved");
}
}
}
どのように私は今、アプリ内でメールに添付し、これをしまうのこの部分を使用してデバイスメモリに写真を撮ると保存しますか?私はあなたがあなたの意図を構築しながらこれだけを追加し、メールを送信する意図を使用しようとしていると思うと任意の助けは常に感謝
笑それは本当に簡単ですか!ありがとう@Anto –
有効になったおかげで再び6minsと私は私の答えとしてマークすることができます笑 –