Пример #1
0
  /**
   * Unsubscribes from a given Amazon SNS topic.
   *
   * @param topic topic to unsubscribe from
   */
  public void unsubscribeFromTopic(final SnsTopic topic) {
    // Rely on the status stored locally even though it's likely that the device is
    // subscribed to a topic, but the subscription arn is lost, say due to clearing app data.
    if (!topic.isSubscribed()) {
      return;
    }

    final UnsubscribeRequest request = new UnsubscribeRequest();
    request.setSubscriptionArn(topic.getSubscriptionArn());
    sns.unsubscribe(request);

    // update topic and save subscription in shared preferences
    topic.setSubscriptionArn("");
    sharedPreferences.edit().putString(topic.getTopicArn(), "").commit();
  }
 /**
  * Constructs a new UnsubscribeRequest object. Callers should use the setter or fluent setter
  * (with...) methods to initialize any additional object members.
  *
  * @param subscriptionArn The ARN of the subscription to be deleted.
  */
 public UnsubscribeRequest(String subscriptionArn) {
   setSubscriptionArn(subscriptionArn);
 }