我正在尝试关注this guide.
我的GCM应用程序通过扩展WakefulBroadcastReciver的类接收消息。收到gcm消息后,我执行GcmIntentService,通过以下代码处理消息。 。
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="EAP" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:/pscDataSource2</jta-data-source>
<jar-file></jar-file> //fix
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect" />
<property name="hibernate.jdbc.batch_size" value="50" />
<property name="hibernate.show_sql" value="false" />
<property name="hibernate.format_sql" value="true" />
<property name="hibernate.generate_statistics" value="false" />
<property name="hibernate.id.new_generator_mappings" value="false" />
<property name="hibernate.ejb.interceptor" value="com.myPackage.interceptor.DelegatingInterceptor" />
</properties>
</persistence-unit>
</persistence>
我的AndroidManifest.xml定义服务如下。 。
public class GcmBroadcastReceiver extends WakefulBroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
// Explicitly specify that GcmIntentService will handle the intent.
GlobalStuff.GCT = context.getApplicationContext();
ComponentName comp = new ComponentName(context.getPackageName(),
GcmIntentService.class.getName());
// Start the service, keeping the device awake while it is launching.
startWakefulService(context, (intent.setComponent(comp)));
setResultCode(Activity.RESULT_OK);
}
}
该指南仅讨论了InstanceIDListenerService,GcmListenerService和GcmPubSub的迁移。如果我使用GcmBroadcastReceiver,则没有讨论该怎么做。我该怎么办?某处是否有更好的迁移指南?