我尝试使用pushbots服务在我的Android应用程序中实现推送通知。该应用程序打开良好。但是当我从pushbots服务发送推送通知时,应用程序崩溃了。我无法解决问题。这是我的mainactivity.java
import com.pushbots.push.Pushbots;
public class MainActivity extends FragmentActivity implements
ActionBar.TabListener
{ protected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);`
setContentView(R.layout.activity_main);
Pushbots.sharedInstance().init(this);
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
viewpager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { }
@Override
public void onPageSelected(int position) {
actionBar.setSelectedNavigationItem(position);
}
这是我的pushbots.xml文件:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Pushbots Application ID -->
<string name="pb_appid">124556532</string>
<!-- GCM Sender ID -->
<string name="pb_senderid">axsd1244</string>
<!-- Pushbots Log Level log Tag "PB2" -->
<string name="pb_logLevel">DEBUG</string>
</resources>
这是我的清单文件:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.codes.pushnotification.app" >
<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" />
<permission android:name="com.codes.pushnotification.app.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="com.codes.pushnotification.app.permission.C2D_MESSAGE" />
<!-- This app has permission to register and receive dataf message. -->
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<intent-filter>
<action android:name="com.codes.pushnotification.app.MESSAGE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<receiver
android:name="com.pushbots.google.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="com.codes.pushnotification.app" />
</intent-filter>
</receiver>
<receiver android:name="com.pushbots.push.DefaultPushHandler" />
<service android:name="com.pushbots.push.GCMIntentService" />