콜백 -> Android Kotlin 라이브러리를 사용하여 다른 애플리케이션과 이미지 공유
6651 단어 androidlibrarieskotlincoroutines
Kotlin Coroutines가 지원하는 Android용
Image
및 Text
공유 라이브러리. Share
는 다음과 같습니다.빠름:
Share
는 Background Thread
를 사용하여 Coroutines
에서 작업을 수행합니다. 경량:
Share
APK에 ~10개 메서드를 추가합니다(이미 코루틴을 사용하는 앱의 경우). 사용 용이성:
Share's
API는 단순성과 최소한의 상용구를 위해 Kotlin의 언어 기능을 활용합니다. 현대:
Share
코루틴을 사용합니다. 구현
Share
는 jitpack
에서 사용할 수 있습니다.그라들
루트
build.gradle
파일(모듈/앱 build.gradle 파일 아님)에 아래 코드를 추가하세요.allprojects {
repositories {
....
maven { url 'https://jitpack.io' }
}
}
그리고 APP의
build.gradle
파일에 종속성 코드를 추가합니다.dependencies {
implementation 'com.github.EsmaeelNabil:Share-em:1.0.7'
}
용법
간단한 사용법
Share.with(context = this)
.item(SharableItem(pictureUrl = "ImageUrl"),
onStart = {},
onFinish = { isSuccessful, errorMessage -> })
Share.with(context = this)
.item(SharableItem(data = "Text To Share"),
onStart = {},
onFinish = { isSuccessful, errorMessage -> })
더 구체적인 예
Share.with(context = this).item(SharableItem(
pictureUrl = "https://images.unsplash.com/photo-1554290712-e640351074bd?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=965&q=80",
data = "body text", //default = ""
shareAppLink = false, // don't generate appliaction playstore `download our app` message with the data text. default = false
downloadOurAppMessage = "Find us here" // A custom message for AppLink sharing feature
),
onStart = {
// do something onStart like : Loading
Log.e(TAG, "Sharing Started.")
},
onFinish = { isSuccessful: Boolean, errorMessage: String ->
// if isSuccessful : you will see an intent chooser
// else : check the error message
if (isSuccessful)
Log.e(TAG, "Successfully shared")
else
Log.e(TAG, "error happened : $errorMessage")
}
)
팁
pictureUrl = "ImageUrl"
가 valid
URL이 아닌 경우 data
텍스트만 공유하게 됩니다. downloadOurAppMessage is provided and
shareAppLink`가 false이면 무시됩니다. Reference
이 문제에 관하여(콜백 -> Android Kotlin 라이브러리를 사용하여 다른 애플리케이션과 이미지 공유), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://dev.to/esmaeelnabil/share-images-with-other-applications-with-callbacks-android-kotlin-library-4fio텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)