1
私のアンドロイドアプリケーションでは、ボタンを最初にクリックするとカメラが開き、画像をキャプチャすると新しい動作にリダイレクトされます。ボタンをクリックするまでカメラが開きません - android
しかし、私が最初にボタンをクリックすると、新しいアクティビティにリダイレクトされ、戻るボタンをクリックするとカメラが開きます。
私のコードで何が問題なのか分かりませんが、うまくできているようです。助けてください。
public void onCameraButtonClicked()
{
camera_btn.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
final String dir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES) + "/picFolder/";
makingDirectory(dir);
storePicture(dir);
}
}
);
}
public void makingDirectory(String dir)
{
File newdir = new File(dir);
newdir.mkdirs();
}
public void storePicture(String dir)
{
boolean flag_storePicture = false;
// 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();
Uri outputFileUri = Uri.fromFile(newfile);
Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
startActivityForResult(cameraIntent, TAKE_PHOTO_CODE);
flag_storePicture = true;
Log.d("myApp", "Hiiiiii from inside");
}
catch (IOException e)
{
}
finally {
Log.d("myApp", "Hiiiiii");
Intent camera_intent = new Intent("com.example.lalinda.googlemap1.Camera");
startActivity(camera_intent);
}
}
私はこのメッセージを受け取っています。
Skipped 62 frames! The application may be doing too much work on its main thread.