w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Parse Push - How to Automatically Open an activity without user action on receiving a push on Android

Yes, it's possible. Parse.com documentation says:

You can also specify an Intent to be fired in the background when the push notification is received. This will allow your app to perform custom handling for the notification, and can be used whether or not you have chosen to display a system tray message. To implement custom notification handling, set the Action entry in your push notification data dictionary to the Intent action which you want to fire. Android guidelines suggest that you prefix the action with your package name to avoid namespace collisions with other running apps.

So you send push notifications in this way:

JSONObject data = new JSONObject("{"action":

ParsePush push = new ParsePush();

Then in your AndroidManifest.xml register a broadcast receiver that will be called whenever a push notification is received with an action parameter of com.example.UPDATE_STATUS:

<receiver android:name="com.example.MyBroadcastReceiver"
    <action android:name="com.example.UPDATE_STATUS" />

In your broadcast receiver you can start a new activity:

public class MyBroadcastReceiver extends BroadcastReceiver {

  public void onReceive(Context context, Intent intent) {
    context.startActivity(new Intent(context, MyActivity.class));

© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.