私は通知を通知するためのシグナルライブラリを実装していますが、私はアプリが実行されていない間にプッシュ通知のクリックからペトリキュラのアクティビティを開きたいですよ。 私はpushnotificatonを受け取っていますが、アプリがクラッシュするここでの通知受信のための私のコードはOneSignal Push Notification actiivtyを開くにはここをクリック
パブリッククラスExampleNotificationOpenedHandlerは{
Context context;
@Override
public void notificationOpened(OSNotificationOpenResult result) {
OSNotificationAction.ActionType actionType = result.action.type;
JSONObject data = result.notification.payload.additionalData;
String customKey;
if (data != null) {
customKey = data.optString("customkey", null);
if (customKey != null)
Log.e("OneSignalExample", "customkey set with value: " + customKey);
}
if (actionType == OSNotificationAction.ActionType.ActionTaken)
Log.i("OneSignalExample", "Button pressed with id: " + result.action.actionID);
Intent intent = new Intent(context, User_Detail.class);
intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
}
OneSignal.NotificationOpenedHandlerを実装しているここに私のエラーMSGが
Attempt to invoke virtual method 'java.lang.String android.content.Context.getPackageName()' on a null object reference
おかげで私はコンストラクタでコンテキストを渡すために逃したバディ。 –