Unable to get push notification text

I have created a sample android application for receiving push messages from Parse. I had followed this video tutorial. The application is working fine and I am able to receive push notifications.

The classes required are as follows:

ParseApplication class:

public class ParseApplication extends Application {

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

        // Add your initialization code here
        Parse.initialize(this, "ygdC4y3uzCe0TOEPOfB1U469Gg5ZJGxF2OGlNKCG", "Tk5ZlDiWWVJm2Xio5IiXk0KI5JM1jrvGPOSpFxzE");

        PushService.setDefaultPushCallback(ParseApplication.this, SampleClass.class);



        ParseUser.enableAutomaticUser();
        ParseACL defaultACL = new ParseACL();

        // If you would like all objects to be private by default, remove this line.
        defaultACL.setPublicReadAccess(true);

        ParseACL.setDefaultACL(defaultACL, true);
    }

}

ParseStarterProjectActivity class:

public class ParseStarterProjectActivity extends Activity {
    /** Called when the activity is first created. */
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        ParseAnalytics.trackAppOpened(getIntent());


    }
}

SampleClass class:

public class SampleClass extends Activity {

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

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.sample_class, menu);
        return true;
    }

}

The manifest file:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.parse.starter"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="4"
        android:targetSdkVersion="15" />

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />

    <!--
  IMPORTANT: Change "com.parse.starter.permission.C2D_MESSAGE" in the lines below
  to match your app's package name + ".permission.C2D_MESSAGE".


    -->
    <permission
        android:name="com.parse.starter.permission.C2D_MESSAGE"
        android:protectionLevel="signature" />

    <uses-permission android:name="com.parse.starter.permission.C2D_MESSAGE" />

    <application
        android:name="com.parse.starter.ParseApplication"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:name="com.parse.starter.ParseStarterProjectActivity"
            android:label="Test Push" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name="com.parse.starter.MainActivity"
            android:label="Test Push" >
        </activity>

        <service android:name="com.parse.PushService" />

        <receiver android:name="com.parse.ParseBroadcastReceiver" >
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
                <action android:name="android.intent.action.USER_PRESENT" />
            </intent-filter>
        </receiver>
        <receiver
            android:name="com.parse.GcmBroadcastReceiver"
            android:permission="com.google.android.c2dm.permission.SEND" >
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
                <action android:name="com.google.android.c2dm.intent.REGISTRATION" />

                <!-- IMPORTANT: Change "com.parse.starter" to match your app's package name. -->
                <category android:name="com.parse.starter" />
            </intent-filter>
        </receiver>

        <activity
            android:name="com.parse.starter.SampleClass"
            android:label="@string/title_activity_sample_class" >
        </activity>
    </application>

</manifest>

Now I want to get text from the push notifications when the user receives them. What should I do to get the text from the notifications?

This is the url to the push notification server.

I even went though this.

Answers


I had to change the SampleClass Activity like this:

public class SampleClass extends Activity {

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

        Intent intent = getIntent(); 
        Bundle extras = intent.getExtras(); 
        String jsonData = extras.getString( "com.parse.Data" );

        Log.i("Data Received:", jsonData);

    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.sample_class, menu);
        return true;
    }

The rest is as it is. I referred this link.


Need Your Help

How can I open several files at once in Vim?

vim

Is there a way to open all the files in a directory from within Vim? So a :command that would say in effect "Open all the files under /some/path into buffers".

Combining three EXISTS

ssas mdx olap olap-cube

How do we get the intersection of the following three sets?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.