theta4j can make it easier to use the WebAPI inside of the THETA Plug-in.
Client implementation of RICOH THETA API v2.1. Contribute to theta4j/theta-web-api development by creating an account on GitHub.
There’s some nice examples in both Kotlin and Java. The Kotlin examples are especially useful if you want to learn Kotlin. The primary example is in the folder plugin-example. It builds with no problems.
package org.theta4j.webapi.example.plugin
import android.os.Bundle
import android.view.KeyEvent
import com.theta360.pluginlibrary.activity.PluginActivity
import com.theta360.pluginlibrary.callback.KeyCallback
import com.theta360.pluginlibrary.receiver.KeyReceiver
import org.theta4j.webapi.CaptureMode
import org.theta4j.webapi.Options.CAPTURE_MODE
import org.theta4j.webapi.Theta
import java.util.concurrent.Executors
class MainActivity : PluginActivity() {
private val executor = Executors.newSingleThreadExecutor()
private val theta = Theta.createForPlugin()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
setAutoClose(true);
}
override fun onResume() {
super.onResume()
setKeyCallback(keyCallback)
executor.submit {
theta.setOption(CAPTURE_MODE, CaptureMode.IMAGE)
}
}
override fun onPause() {
super.onPause()
setKeyCallback(null)
}
private val keyCallback = object : KeyCallback {
override fun onKeyDown(keyCode: Int, keyEvent: KeyEvent) {
if (keyCode == KeyReceiver.KEYCODE_CAMERA) {
executor.submit {
theta.takePicture()
}
}
}
override fun onKeyUp(keyCode: Int, keyEvent: KeyEvent) {
}
override fun onKeyLongPress(keyCode: Int, keyEvent: KeyEvent) {
}
}
}
The README has useful examples.
theta4j/theta-web-api/blob/master/README.md
# THETA Web API Client
[![Javadocs](https://javadoc.io/badge/org.theta4j/theta-web-api.svg)](https://javadoc.io/doc/org.theta4j/theta-web-api)
Client implementation of [RICOH THETA API v2.1](https://developers.theta360.com/en/docs/v2.1/api_reference/).
Supported environments are Java, JVM languages, Android, and THETA Plug-in.
Tested on RICOH THETA V. Some features for THETA S and SC are not tested.
## Getting Started
Modify your `build.gradle` to include this library.
```groovy
repositories {
...
jcenter() // insert this line
}
(This file has been truncated. show original)
There’s a few points below that I used when creating a new plug-in from scratch.
add to build.gradle Project
maven { url 'https://github.com/ricohapi/theta-plugin-library/raw/master/repository' }
add to build.gradle (Module: app)
implementation 'com.theta360:pluginlibrary:2.0.0'
implementation 'org.theta4j:theta-web-api:1.2.2'
Add compile options:
android {
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
}
Sync Gradle files.
In AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET"/>