我正在使用 Parse 推送通知来为我的安卓应用提供服务。我按照教程下载了 JAR 文件,并将其导入到我的项目中,然后将以下代码添加到我的清单文件中:
在我的主活动中,我这样做
有人说这可能是应用程序清单中名称属性的问题,所以我使用我的包名添加了这行代码。
<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>
我将application.class添加到了我的包中,代码如下:
public class Application extends android.app.Application {
public Application() {
}
@Override
public void onCreate() {
super.onCreate();
// Initialize the Parse SDK.
Parse.initialize(this, "zzxxxxxxxxxxxxxxVv", "wyxxxxxxxCElxxxxxxx");
// Specify a Activity to handle all pushes by default.
PushService.setDefaultPushCallback(this, MainActivity.class);
// Save the current installation.
ParseInstallation.getCurrentInstallation().saveInBackground();
}
}
在我的主活动中,我这样做
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ParseAnalytics.trackAppOpened(getIntent());
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
Log.e("MainActivity", "oncreate");
setContentView(R.layout.activity_main);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
有人说这可能是应用程序清单中名称属性的问题,所以我使用我的包名添加了这行代码。
<application
android:name="com.test.pushnotificationTest.Application"
在 Parse 仪表盘中,当我在新设备上安装应用程序后,我会在仪表盘中得到新的条目。但是,当我尝试发送推送通知时,我却没有收到通知。 我需要添加广播接收器吗?但是以前使用同样的代码而没有广播也可以工作。 请帮帮我。