title: How to get the endpoint ARN after the user re-install the android app for Amazon SNS?
body: <p>Currently I am using Amazon SNS for managing the google GCM , which is to push the notification.</p>
  
  <p>The problem is , I can only get the endpoint ARN after create the end point like this, </p>
  
  <p>but how can I check whether the user has register before? So I do not need to create one more record </p>
  
  <p>and just use that old record. Thanks</p>
  
  <p>The code below is a button for the user to turn on (register) / off (delete) the SNS in amazon</p>
  
  <pre><code>notify.setOnClickListener(new OnClickListener() {
      @SuppressWarnings({ "rawtypes", "unchecked" })
      @Override
      public void onClick(View v) {
          if (prefs.getString("endpoint_arn", "").equals("")) {
              new AsyncTask() {
                  @Override
                  protected Object doInBackground(final Object... params) {                                       
                      try {
                          ((Activity) ctx).runOnUiThread(new Runnable() {
                                public void run() {
                                    if (!pDialog.isShowing())
                                          pDialog.show();
                                }
                          });
  
                          String token = gcm.register(Constant.projectID);
  
                          CreatePlatformEndpointRequest per = new CreatePlatformEndpointRequest();
                          per.setToken(token);
                          per.setPlatformApplicationArn(Constant.platformARN);
  
                          CreatePlatformEndpointResult result = asnsc.createPlatformEndpoint(per);
  
                          editor.putString("endpoint_arn", result.getEndpointArn());
                          editor.commit();
  
                          ((Activity) ctx).runOnUiThread(new Runnable() {
                                public void run() {
                                    notify_txt.setText(ctx.getResources().getString(R.string.on));
                                    if (pDialog.isShowing())
                                        pDialog.dismiss();
                                }
                          });
  
                      } catch (final Exception e) {
                          ((Activity) ctx).runOnUiThread(new Runnable() {
                                public void run() {
                                    Log.d("test1","Registration Error:" + e.getMessage());
                                    Toast.makeText(ctx, getResources().getString(R.string.error),  Toast.LENGTH_LONG).show();
                                    if (pDialog.isShowing())
                                        pDialog.dismiss();
                                }
                          });
                      }
                      return true;
                  }
              }.execute(null, null, null);
  
          } else {
  
              new AsyncTask() {
                  @Override
                  protected Object doInBackground(final Object... params) {                                       
                      try {
                          ((Activity) ctx).runOnUiThread(new Runnable() {
                                public void run() {
                                    if (!pDialog.isShowing())
                                          pDialog.show();
                                }
                          });
  
                          DeleteEndpointRequest dPer = new DeleteEndpointRequest();
                          dPer.setEndpointArn(prefs.getString("endpoint_arn", ""));
                          asnsc.deleteEndpoint(dPer);
                          gcm.unregister();
                          editor.remove("endpoint_arn").commit();
  
                          ((Activity) ctx).runOnUiThread(new Runnable() {
                                public void run() {
                                    notify_txt.setText(ctx.getResources().getString(R.string.off));
                                    if (pDialog.isShowing())
                                        pDialog.dismiss();
                                }
                          });
  
                      } catch (final Exception e) {
                          ((Activity) ctx).runOnUiThread(new Runnable() {
                                public void run() {
                                    Log.d("test1","Delete Error:" + e.getMessage());
                                    Toast.makeText(ctx, getResources().getString(R.string.error),  Toast.LENGTH_LONG).show();
                                    if (pDialog.isShowing())
                                        pDialog.dismiss();
                                }
                          });
                      }
                      return true;
                  }
  
  
              }.execute(null, null, null);
  
          }
  
      }
  });
  </code></pre>