I am trying to develop a camera app. In which I need to capture an image and just after that before saving I need to add some text over the captured image. Is it possible to edit the captured image at a run time in android please suggest me?
activity_camera.xml
<ImageView
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:id="@+id/imageView"
android:layout_weight="9"
/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/btnCamera"
android:layout_weight="1"
android:background="@android:color/holo_blue_dark"
android:textColor="@android:color/white"
android:text="Open Camera"
/>
CameraActivity.java
public class CameraActivity extends Activity {
private ImageView imageView;
private Camera camera;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_camera);
Button btnCamera = (Button)findViewById(R.id.btnCamera);
imageView = (ImageView)findViewById(R.id.imageView);
btnCamera.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(CameraActivity.this, "Camera Text", Toast.LENGTH_SHORT).show();
File file = new File(getExternalFilesDir(Environment.DIRECTORY_PICTURES), "Test.jpg");
Uri iImageOutputUri = Uri.fromFile(file);
AppPermission appPermission = new AppPermission(CameraActivity.this);
if (!appPermission.checkPermissionForCamera()) {
appPermission.requestPermissionForCamera();
}else {
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent,0);
}
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Toast.makeText(CameraActivity.this, "Camera Text 2", Toast.LENGTH_SHORT).show();
// Process result for camera activity.
// If camera take picture success.
if (resultCode == RESULT_OK) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String currentDateandTime = sdf.format(new Date());
Toast.makeText(this, currentDateandTime, Toast.LENGTH_SHORT).show();
Bitmap bitmap = (Bitmap) data.getExtras().get("data");
imageView.setImageBitmap(bitmap);
}
}
}