Created
August 5, 2020 03:48
-
-
Save Goropocha/e4830c66fb1b609b552e88669c4cc44b to your computer and use it in GitHub Desktop.
ADM MessageHandler
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.your.packagename; | |
| import android.content.Context; | |
| import android.content.Intent; | |
| import com.amazon.device.messaging.ADMMessageHandlerJobBase; | |
| /** | |
| * ADMメッセージハンドラ | |
| */ | |
| public class MyADMMessageHandler extends ADMMessageHandlerJobBase { | |
| public MyADMMessageHandler() { | |
| super(); | |
| } | |
| @Override | |
| protected void onRegistered(final Context context, final String newRegistrationId) | |
| { | |
| // メインアクティビティでstartRegister()を呼び出して登録プロセスを | |
| // 開始します。登録IDが利用可能になると、ADMはアプリのonRegistered()を | |
| // 呼び出します。開発者サーバーが現在のアプリインスタンスにメッセージを送信できるように、 | |
| // 渡された登録IDを開発者サーバーに送信します。onRegistered()は、何らかの理由で | |
| // 登録IDのローテーションまたは変更が行われた場合にも呼び出されます。 | |
| // その場合、アプリ側は新しい登録IDを開発者サーバーに渡す必要があります。 | |
| // 開発者サーバーは、最大1,536文字の登録IDを処理できる | |
| // 必要があります。 | |
| } | |
| @Override | |
| protected void onUnregistered(final Context context, final String registrationId) | |
| { | |
| // このデバイスでアプリが登録解除されている場合は、現在のアプリインスタンスが | |
| // メッセージの有効なターゲットではなくなっていることを、開発者サーバーに通知します。 | |
| } | |
| @Override | |
| protected void onRegistrationError(final Context context, final String errorId) | |
| { | |
| // 登録エラーは致命的であるとみなす必要があります。その対応として、 | |
| // アプリの機能を適切に制限するか、アプリの機能のうちこの部分が使用できないことを | |
| // ユーザーに通知することができます。 | |
| Debug.out("ADM Registration Error. errorId : " + errorId); | |
| } | |
| @Override | |
| protected void onMessage(final Context context, final Intent intent) | |
| { | |
| // com.amazon.device.messaging.intent.RECEIVEインテントに | |
| // アタッチされているエクストラからメッセージコンテンツを抽出します。 | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment