fun openPDF(path: String?) {
if (!TextUtils.isEmpty(path)) {
val u_path = Uri.parse(path)
val intent = Intent(Intent.ACTION_VIEW)
intent.setDataAndType(u_path, "application/pdf")
intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP
try {
mContext.startActivity(intent)
} catch (e: ActivityNotFoundException) {
Toast.makeText(mContext, "PDF 파일을 보기 위한 뷰어 앱이 없습니다.", Toast.LENGTH_SHORT).show()
}
} else {
Toast.makeText(mContext, "PDF 파일이 없습니다.", Toast.LENGTH_SHORT).show()
}
}
'프로그래밍 > Android' 카테고리의 다른 글
android architecture components (AAC) 설명 및 샘플코드 (0) | 2020.02.21 |
---|---|
GradientDrawable활용 button shape selector 코드 처리 (0) | 2017.07.20 |
안드로이드스튜디오 단축키 (0) | 2016.07.15 |
[Android]Android, MySQL, PHP, & JSON Tutorial (0) | 2014.12.03 |
[Android] Handler{} sending message to a Handler on a dead thread (0) | 2012.12.11 |