Ich möchte verschiedene Klassen öffnen, abhängig vom Inhalt der Benachrichtigung, die ich erhalten habe. Ich bin in der Lage, die MainActivity-Klasse bei einem Benachrichtigungsklick zu öffnen, aber nicht bei OpenActivityOne. Ich kenne den Grund nicht.kann Aktivität bei Benachrichtigung nicht öffnen klicken
private void sendNotification(String msg) {
Log.d(TAG, "Preparing to send notification...: " + msg);
mNotificationManager = (NotificationManager) this
.getSystemService(Context.NOTIFICATION_SERVICE);
if(msg.equalsIgnoreCase("Call")){
System.out.println("Inside iffffffffffffffffffffff");
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
new Intent(this, OpenActivityOne.class), 0);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(
this).setSmallIcon(R.drawable.gcm_cloud)
.setContentTitle("GCM Notification")
.setStyle(new NotificationCompat.BigTextStyle().bigText(msg))
.setContentText(msg);
mBuilder.setContentIntent(contentIntent);
mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
}else{
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
new Intent(this, MainActivity.class), 0);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(
this).setSmallIcon(R.drawable.gcm_cloud)
.setContentTitle("GCM Notification")
.setStyle(new NotificationCompat.BigTextStyle().bigText(msg))
.setContentText(msg);
mBuilder.setContentIntent(contentIntent);
mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
}
Log.d(TAG, "Notification sent successfully.");
}
OpenActivityOne.java
public class OpenActivityOne extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
Toast.makeText(getApplicationContext(), "Open OpenActivityOne",
Toast.LENGTH_LONG).show();
}
}
Wahrscheinlich zwei Gründe: 1. 'OpenActivityOne' ist nicht hinzugefügt in' AndroidManifest.xml' und 2. 'msg' ist nicht gleich 'Call', für den zweiten Fall versuchen Sie es mit' String.contains' –
@ ρяσѕρєяK es ist In AndroidManifest deklariert wäre sonst schon viel Fehler aufgetreten. und es dringt in das Innere ein, wenn es mit log - System.out.println (innerhalb von iffff) überprüft wird; – SwagDevelopers
ok dann füge log 'onCreate 'von' OpenActivityOne 'hinzu und überprüfe, ob' OpenActivityOne 'ausgeführt wird oder nicht –