- Android 6+
- Studyplus App 7.0.+
Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.studyplus:Studyplus-Android-SDK:4.0.0'
}
If you want to handle StudyplusSDK instance as a singleton, use Dagger.
private val instance by lazy {
Studyplus(
context = this,
consumerKey = "consumer_key",
consumerSecret = "consumer_secret",
)
}
Open an Activity to connect with Studyplus.
instance.startAuth(this@MainActivity, REQUEST_CODE_AUTH)
Then save the result.
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (resultCode != RESULT_OK || data == null) {
Toast.makeText(this, "error!!", Toast.LENGTH_LONG).show()
return
}
if (requestCode == REQUEST_CODE_AUTH) {
instance.setAuthResult(data)
Toast.makeText(this, "Success!!", Toast.LENGTH_LONG).show()
}
}
instance.cancelAuth()
Create a record and post.
val record = StudyRecord(
duration = 2 * 60,
amount = StudyRecordAmountTotal(30),
comment = "勉強した!!!",
)
instance.postRecord(record, object : PostCallback {
override fun onSuccess() {
Toast.makeText(context, "Post Study Record!!", Toast.LENGTH_LONG).show()
}
override fun onFailure(e: StudyplusError) {
Toast.makeText(context, "error!!", Toast.LENGTH_LONG).show()
}
})
- See also Sample Project.
MIT License
Copyright (c) 2021 Studyplus, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.