這是代碼的問題的一部分:意圖之前只允許我用一個活動,沒有允許的AsyncTask
Intent intent = new Intent(MyGcmListenerService.this, CalcularHorariosDisponiblesComplejo.class);
intent.putExtra("idComplejo",idComplejoSeleccionado);
intent.putExtra("idCancha",idCanchaSeleccionada);
intent.putExtra("idUsuarioComplejo",idUsuarioComplejo);
intent.putExtra("idPais",idPais);
intent.putExtra("nombreComplejo", nombreComplejo);
intent.putExtra("dia",day);
intent.putExtra("mes",month);
intent.putExtra("anio",year);
PendingIntent resultPendingIntent =
PendingIntent.getActivity(
MyGcmListenerService.this,
m,
intent,
PendingIntent.FLAG_UPDATE_CURRENT
);//creamos la notificacion
NotificationCompat.Builder n = new NotificationCompat.Builder(MyGcmListenerService.this)
.setContentTitle(titulo)
.setSound(uri)
.setSmallIcon(R.drawable.notification_icon)
.setLargeIcon(bm)
.setStyle(new NotificationCompat.BigTextStyle().bigText("El usuario " + nombreOrigen + " " + mensaje))
.setContentIntent(resultPendingIntent)
.setAutoCancel(true);
NotificationManager notificationManager =
(NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(m, n.build());
}
該工程的PendingIntent很大,但我改變CalcularHorariosDisponiblesComplejo.class了的AsyncTask。現在我所說的sameclass這樣的:
new CalcularHorariosComplejoAsyncTask(MyGcmListenerService.this, idComplejoSeleccionado, idCanchaSeleccionada, nombreComplejo, idUsuarioComplejo, idPais, String.valueOf(day),String.valueOf(month),String.valueOf(year)).execute();
,現在我不能使用掛起的意圖的問題,所以我試圖取代這樣的事情,但不工作:
PendingIntent resultPendingIntent =
PendingIntent.getActivity(
MyGcmListenerService.this,
m,
new CalcularHorariosComplejoAsyncTask(MyGcmListenerService.this, idComplejoSeleccionado, idCanchaSeleccionada, nombreComplejo, idUsuarioComplejo, idPais, String.valueOf(day),String.valueOf(month),String.valueOf(year)).execute(),
PendingIntent.FLAG_UPDATE_CURRENT);
哪有我從PendingIntent呼叫Asynctask?
? –
@MiguelBenitez我不知道,這是最好的解決方案嗎?,如果你這麼認爲,請給出解決方案。謝謝 –
解決方案是'PendingIntent.getService()' – EpicPandaForce