I'm a beginner to Java and android programming and I have followed the tutorials for PushBot to creating a working app. However the app crashes when receiving a push notification if it's not running in the foreground. So I have had a little search on here and the pushbots website and found about extending the class to the application. The problem is I cannot get this method working by extending by application and not the activity. I now been staring at it so long I can't see the wood from the trees and it's probably a really simple fix I get an error on the public class Myapplication line and can't compile (it must be defined in its on file apparently) :
heres the code :
package co.uk.mypchealth.pushbottest;
import com.pushbots.push.Pushbots;
import android.app.Application;
public class MyApplication extends Application {
private String SENDER_ID = "Oh know you dont :) My sender id here ";
private String PUSHBOTS_APPLICATION_ID = "oh know you dont :) my app id here";
@Override
public void onCreate() {
super.onCreate();
Pushbots.init(this, SENDER_ID,PUSHBOTS_APPLICATION_ID); } }
Here is the Mainifest file where I expect it's all going horribly wrong lol.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="co.uk.mypchealth.pushbottest"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<!-- GCM connects to Google Services. -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<!-- GCM requires a Google account. -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<permission android:name="co.uk.mypchealth.pushbottest.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="co.uk.mypchealth.pushbottest.permission.C2D_MESSAGE" />
<!-- This app has permission to register and receive data message. -->
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:name="co.uk.mypchealth.pushbottest.MyApplication"
android:label="@string/app_name"
android:theme="@style/AppTheme"
>
<activity
android:name="co.uk.mypchealth.pushbottest.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="co.uk.mypchealth.pushbottest.MESSAGE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name="com.pushbots.push.PBMsg"/>
<activity android:name="com.pushbots.push.PBListener"/>
<receiver
android:name="com.google.android.gcm.GCMBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<!-- Receives the actual messages. -->
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<!-- Receives the registration id. -->
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="co.uk.mypchealth.pushbottest" />
</intent-filter>
</receiver>
<receiver android:name="com.pushbots.push.MsgReceiver" />
<service android:name="com.pushbots.push.GCMIntentService" />
<service android:name="org.openudid.OpenUDID_service" >
<intent-filter>
<action android:name="org.openudid.GETUDID" />
</intent-filter>
</service>
</application>
</manifest>
These are the pages I've been looking at :
https://pushbots.com/developer/tutorial#/android/new/step/5
PushBots App Crash
Using PushBots for android push notification