在不同的Activity Android中解析Open push通知

时间:2014-05-31 08:58:05

标签: java android parse-platform

我的主要是:

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // Track app opens.
        ParseAnalytics.trackAppOpened(getIntent());
    } }

我的班级应用程序是:

public class Application extends android.app.Application {

      public Application() {
      }

      @Override
      public void onCreate() {
        super.onCreate();

        // Initialize the Parse SDK.

        Parse.initialize(this, "KEY","KEY"); 
        PushService.setDefaultPushCallback(this, MainActivity.class,R.drawable.favicon);
        ParseInstallation.getCurrentInstallation().saveInBackground();
      }
    }

当我点击通知时,它会打开MainActivity,但不会返回推送结果?

1 个答案:

答案 0 :(得分:4)

我解决了它:

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Track app opens.
    ParseAnalytics.trackAppOpened(getIntent());
    Intent i = getIntent();
    Bundle extras = i.getExtras();
    if (extras != null) {
        System.out.println("MESSAGGE " + extras.get("com.parse.Data"));
        System.out.println("Chanell " + extras.get("com.parse.Channel"));
        System.out.println("DATA " + extras.keySet());
        for (String k : extras.keySet()) {
            System.out.println("K " + k);

        }
    }
}}