La aplicación se bloquea si la aplicación se cierra mediante el servicio Push: parse.com
Reemplazo el receptor en manifiesto al mío:
<receiver android:name="com.myparse.app.MyReceiver" android:exported="false"> <intent-filter> <action android:name="com.parse.push.intent.RECEIVE" /> <action android:name="com.parse.push.intent.DELETE" /> <action android:name="com.parse.push.intent.OPEN" /> </intent-filter> </receiver>
Este es mi MyReceiver:
- Implementación de la notificación push del servidor
- Al hacer clic en la notificación no se abre la actividad mencionada
- Despierta Android Phone / tablet?
- Nuevo error de origen desconocido del registro de la API de GCM
- No se puede iniciar la aplicación de receptor com.parse.ParseBroadcastReceiver en Trigger.io
public class MyReceiver extends ParsePushBroadcastReceiver { @Override protected void onPushReceive(Context mContext, Intent intent) { // super.onPushReceive(arg0, arg1); if (intent.hasExtra("com.parse.Data")){ String jsonString=intent.getExtras().getString("com.parse.Data"); //------------- } public void onPushOpen(Context context, Intent intent) { //To track "App Opens" ParseAnalytics.trackAppOpenedInBackground(intent); //Here is data you sent Log.i("", intent.getExtras().getString( "com.parse.Data" )); Intent i = new Intent(context, MainActivity.class); i.putExtras(intent.getExtras()); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(i); } }
Todo funciona bien Pero si cierro la aplicación, y luego enviar una notificación push-> la aplicación se bloquea con los siguientes registros:
11-09 21:13:11.621: E/com.parse.PushService(23087): The Parse push service cannot start because Parse.initialize has not yet been called. If you call Parse.initialize from an Activity's onCreate, that call should instead be in the Application.onCreate. Be sure your Application class is registered in your AndroidManifest.xml with the android:name property of your <application> tag. 11-09 21:13:11.626: E/AndroidRuntime(23087): FATAL EXCEPTION: main 11-09 21:13:11.626: E/AndroidRuntime(23087): java.lang.RuntimeException: Unable to start service com.parse.PushService@4203adb0 with Intent { act=com.google.android.c2dm.intent.RECEIVE flg=0x10 pkg=com.myparse.app cmp=com.myparse.app/com.parse.PushService (has extras) }: java.lang.RuntimeException: applicationContext is null. You must call Parse.initialize(context, applicationId, clientKey) before using the Parse library. 11-09 21:13:11.626: E/AndroidRuntime(23087): at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2782) 11-09 21:13:11.626: E/AndroidRuntime(23087): at dalvik.system.NativeStart.main(Native Method) 11-09 21:13:11.626: E/AndroidRuntime(23087): Caused by: java.lang.RuntimeException: applicationContext is null. You must call Parse.initialize(context, applicationId, clientKey) before using the Parse library. 11-09 21:13:11.626: E/AndroidRuntime(23087): at com.parse.Parse.checkContext(Parse.java:606)
- Servicio de notificación de Google / Apple Push (APNS / GCM)
- Notificación lanza RemoteServiceException en el dispositivo de Motorola con OS 7
- GCM push notificación. Notificación incorrecta publicada - No se pudo expandir RemoteViews para: StatusBarNotification
- No se pueden recibir mensajes con Google Cloud Messaging para Android (no la biblioteca de ayuda)
- Parse Push - Cómo abrir automáticamente una actividad sin la acción del usuario al recibir un empujón en Android
- Firebase Cloud Messaging: mejores prácticas
- Productos de Android Gradle con notificaciones de Parse Push
- Enviar Notificaciones push a iOS / Android en WiFi cerrado (sin conexión a Internet)
Experimenté el mismo problema y lo solucioné agregando android: name = ". MyApplication" a la etiqueta de la aplicación en el manifiesto de Android, y luego creando una nueva clase que se parece a esto:
public class MyApplication extends Application { @Override public void onCreate() { Parse.initialize(getApplicationContext(), myAppId, myClientKey); } }
Anteriormente había puesto la llamada de inicialización de Parse en el método onCreate () de mi actividad principal, pero como el mensaje de error que publicaste sugiere, las sutilezas del ciclo de vida de Android significan que no puedes hacerlo.
- java.lang.NullPointerException: Intenta invocar el método de interfaz 'OnColorChangeListener.colorChanged (java.lang.String)' en una referencia de objeto nulo
- Archivo de cobertura de código Jacoco vacío que conduce a informes de cobertura falsa