PushBot recieving推送通知的应用程序崩溃的不运行时 [英] PushBot recieving push notifications crashes app when its not running

查看:145
本文介绍了PushBot recieving推送通知的应用程序崩溃的不运行时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是初学者对Java和Android编程,我已经遵循PushBot教程创建工作的应用程序。然而,应用程序接收推送通知时崩溃,如果它不是在前台运行。所以我对这里一点搜索和pushbots网站,发现关于类延伸到应用程序。问题是我无法通过应用程序而不是活动扩展得到这种方法工作。我现在它一直盯着这么久,我不能看到从树不见林,这可能是一个非常简单的解决我上公共类MyApplication的路线错误,并且不能编译(必须在其定义的文件显然):

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) :

继承人的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);     }  } 

下面是Mainifest文件,其中我希望这一切都将严重错误笑。

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/新/步/ 5

PushBots应用程序崩溃

<一个href=\"http://stackoverflow.com/questions/18853064/using-pushbots-for-android-push-notification\">Using Android的推送通知 PushBots

Using PushBots for android push notification

推荐答案

检查YouTube上的视频教程(的 http://www.youtube.com/watch?v=faop6vBBe3E

Check the video tutorial on youtube (http://www.youtube.com/watch?v=faop6vBBe3E)

我就太在这里引用:

请确保您复制PushBots.jar文件到库文件夹
  你的Andr​​oid项目。同时也确保您的扩展应用
  级,并在其onCreate方法初始化PushBots,退房
  在这个链接查看更多细节步骤6,7
   https://pushbots.com/developer/tutorial#/android/existing/step / 4

Please make sure you've copied PushBots.jar file into libraries folder of your android project. And also make sure you extended Application Class, and initialized PushBots in its onCreate method, check out steps 6,7 in this link for more details https://pushbots.com/developer/tutorial#/android/existing/step/4

步骤6,7

下面是一个示例code:

here's a sample code:

import com.pushbots.push.Pushbots;
import android.app.Application;

public class MyApplication extends Application {
@Override public void onCreate() { >super.onCreate();
Pushbots.init(this, "",""); }
}

这篇关于PushBot recieving推送通知的应用程序崩溃的不运行时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆