Skip to content

Commit 47d711a

Browse files
authored
Merge pull request #79733 from spelluru/nhubkindlge0614-2
Added the missing code
2 parents 91c4d82 + b8edd0a commit 47d711a

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

articles/notification-hubs/notification-hubs-kindle-amazon-adm-push-notification.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,36 @@ In this tutorial, you create/update code to do the following tasks:
321321
mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
322322
}
323323
```
324+
## Create an ADM object
325+
1 In the `MainActivity.java` file, add the following import statements:
326+
327+
```java
328+
import android.os.AsyncTask;
329+
import android.util.Log;
330+
import com.amazon.device.messaging.ADM;
331+
```
332+
2. Add the following code at the end of the `OnCreate` method:
333+
334+
```java
335+
final ADM adm = new ADM(this);
336+
if (adm.getRegistrationId() == null)
337+
{
338+
adm.startRegister();
339+
} else {
340+
new AsyncTask() {
341+
@Override
342+
protected Object doInBackground(Object... params) {
343+
try { MyADMMessageHandler.getNotificationHub(getApplicationContext()).register(adm.getRegistrationId());
344+
} catch (Exception e) {
345+
Log.e("com.wa.hellokindlefire", "Failed registration with hub", e);
346+
return e;
347+
}
348+
return null;
349+
}
350+
}.execute(null, null, null);
351+
}
352+
```
353+
324354
325355
## Add your API key to your app
326356
1. Follow these steps to add an assets folder to the project.

0 commit comments

Comments
 (0)