Android通知无法打开我的活动

时间:2018-02-13 21:04:29

标签: android android-intent android-activity

我有一个前台服务,其通知应该打开一个活动,只有我无法让它工作......

以下是我设置通知的方式:

myArray.indexOf(2) - myArray.indexOf(1)

修改

我只是使用了错误的功能。

2 个答案:

答案 0 :(得分:1)

// Build Firebase credential with the Facebook access token. var credential = firebase.auth.FacebookAuthProvider.credential(access_token); // Sign in with credential from the Google user. firebase.auth().signInWithCredential(credential).catch(function(error) { // Handle Errors here. var errorCode = error.code; var errorMessage = error.message; // The email of the user's account used. var email = error.email; // The firebase.auth.AuthCredential type that was used. var credential = error.credential; // ... }); (顾名思义)用于运行PendingIntent.getService。如果您要发布Service,则需要使用PendingIntent.getActivity

答案 1 :(得分:1)

使用:

PendingIntent pendingIntent = PendingIntent.getService(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);

根据docs,您正在设置启动服务的意图。 要开始活动,您应该调用getActivity:

PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);