android {
...
// Configure only for each module that uses Java 8
// language features (either in its source code or
// through dependencies).
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
protected void onCreate(Bundle savedInstanceState) {
...
// new Alli(String apiKey, WebView webView, AlliEventHandler eventHandler, boolean showHeader, boolean showFooter, boolean showBackButton)
// showHeader - optional, default: true, If you want to remove the header, turn off this option.
// showFooter - optional, default: true, If you want to remove the footer, turn off this option.
// showBackButton - optional, default: true, If you want to remove the back button on the header, turn off this option.
alli = new Alli("YOUR_API_KEY", webView, this, true, true, false);
alli.initialize();
...
}
public protocol AlliEventHandler {
// Called when initialized successfully.
// You may receive NOT_INITIALIZE_YET error if
// called before this event.
void onInitialized(WebView view);
// Called when chat started successfully.
void onConversationStarted(WebView view, String userId, String placement, Object context);
// Called when conversation did not start
// even when Alli.event was called.
void onConversationNotStarted(_ view: WKWebView!, userId: String, placement: String, context: Any?)
// Called when user has closed the chat
// window or Alli.close() is called.
void onConversationClosed(WebView view, String userId, String placement, Objective context)
void onError(WebView view, AlliErrorCode errorCode, String userId, String placement, Object context)
}
Step 8. 他のアプリと接続
他のアプリに接続するには、次のように入力します。以下は、Googleマップにリンクする例です。
@Override
public boolean handleUrlLoading(String url) {
Uri gmmIntentUri = Uri.parse("geo:37.4919653,127.0330243");
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
mapIntent.setPackage("com.google.android.apps.maps");
startActivity(mapIntent);
return true;