파이어베이스에 보내지 않고 다른 액티비티 뷰페이저로 이동 성공
하지만 기존에 있던 상태에서 계속 add되게 해야함
val imagePath = intent.getStringExtra("path")
// photoList.apply {
// add(Photo(imagePath.toString()))
// Log.d("GET/path", imagePath.toString())
// }
Log.d("GETGET", photoList.toString())
photoList.add(Photo(imagePath.toString()))
Log.d("GET/path", imagePath.toString())
받는 쪽에선 getString을 이용하기
내가 이미지를 넣어야하는 것은 받는쪽 액티비티에서 뷰페이저이다.
하지만 계속 add되지 않음
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityCodingcamerashootingBinding.inflate(layoutInflater)
setContentView(binding.root)
// 권한 체크
val hasCamPerm =
checkSelfPermission(Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED
val hasWritePerm =
checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED
if (!hasCamPerm || !hasWritePerm) // 권한 없을 시 권한설정 요청
ActivityCompat.requestPermissions(
this,
arrayOf(Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE),
1
)
onClick()
}
@SuppressLint("NonConstantResourceId", "QueryPermissionsNeeded")
fun onClick() {
binding.camerashootingGalleryIv.setOnClickListener {
intent = Intent(Intent.ACTION_PICK)
intent.type = MediaStore.Images.Media.CONTENT_TYPE
intent.type = "image/*"
startActivityForResult(intent, GALLERY)
binding.camerashootingCheckIb.visibility=View.VISIBLE
binding.camerashootingturnIb.visibility=View.VISIBLE
binding.camerashootingBnv.visibility=View.VISIBLE
}
binding.camerashootingCheckIb.setOnClickListener {
intent = Intent(applicationContext, CheckCodingQuestionActivity::class.java)
intent.putExtra("path", imagePath)
startActivity(intent)
Log.d("PUT/path", imagePath)
}
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (resultCode == RESULT_OK) { // 결과가 있을 경우
if (requestCode == GALLERY) { // 갤러리 선택한 경우
// 1) data의 주소 사용하는 방법
imagePath = data?.dataString!! // "content://media/external/images/media/7215"
}
if (imagePath.length > 0) {
Glide.with(this)
.load(imagePath)
.into(binding.ivPre)
binding.ivPre.visibility=View.VISIBLE
}
}
}
참고한 블로그
https://teamblog.tistory.com/22
이미지 받아 다른 액티비티에 전달하기
코드는 이미지 가져오기 관련 첫 글에서 이어집니다. 화면 - activity_get_image.xml 이미지를 카메라 또는 갤러리에서 받아오는 화면 <?xml version="1.0" encoding="utf-8"?> - activity_set_image.xml 받아온..
teamblog.tistory.com
이미지 리프레쉬되게 하기
+버튼 대신 편집버튼이 보이게
다음 화면에 +버튼
'무물컴 앱개발기록' 카테고리의 다른 글
개발일지 25 - 3/2 (0) | 2022.03.03 |
---|---|
개발일지 24 - 3/1 (0) | 2022.03.02 |
개발일지 22 -2/25 (0) | 2022.02.28 |
개발일지 21 - 2/18 (0) | 2022.02.19 |
개발일지 20 - 2/16 (0) | 2022.02.17 |