onSuccess 方法未在 android 中调用 firebase
onSuccess method not calling in firebase in android
我正在尝试创建一个动态 link,当我尝试调试代码时,它正在调用回调方法 addOnSuccessListener 但之后它没有调用,或者我们说它正在跳过 onSuccess() 方法,我我不知道为什么会这样。
private void firebaseInvite() {
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
String uid = user.getUid();
String url = "https://larky.funswitch.io/?invitedby=" + uid;
FirebaseDynamicLinks.getInstance().createDynamicLink()
.setLink(Uri.parse(url))
.setDynamicLinkDomain("https://fmu3k.app.goo.gl")
.setAndroidParameters(
new DynamicLink.AndroidParameters.Builder("io.funswitch.funrooster")
.setMinimumVersion(5)
.build())
.buildShortDynamicLink()
.addOnSuccessListener(shortDynamicLink -> {
在此之后我的调试器跳过这段代码并且它没有调用
mInvitationUrl = shortDynamicLink.getShortLink();
mDatabase.child("Name").addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
String referrerName = dataSnapshot.getValue(String.class);
String subject = String.format("%s wants you to play MyExampleGame!", referrerName);
String invitationLink = mInvitationUrl.toString();
String msg = "Let's play MyExampleGame together! Use my referrer link: "
+ invitationLink;
String msgHtml = String.format("<p>Let's play MyExampleGame together! Use my "
+ "<a href=\"%s\">referrer link</a>!</p>", invitationLink);
Intent intent = new Intent(Intent.ACTION_SENDTO);
intent.setData(Uri.parse("mailto:")); // only email apps should handle this
intent.putExtra(Intent.EXTRA_SUBJECT, subject);
intent.putExtra(Intent.EXTRA_TEXT, msg);
intent.putExtra(Intent.EXTRA_HTML_TEXT, msgHtml);
if (intent.resolveActivity(getActivity().getPackageManager()) != null) {
startActivity(intent);
}
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
});
}
请帮帮我..
我解决了这是一个非常基本的愚蠢错误,我实际上正在做 link 没有在上面的代码中解析,因为我在动态 link 和动态 [=13] 中提到了两次 https =] 域从动态 link 域中删除 https 后我得到它的工作。
private void firebaseInvite() {
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
String uid = user.getUid();
String url = "https://larky.funswitch.io/?invitedby=" + uid;
FirebaseDynamicLinks.getInstance().createDynamicLink()
.setLink(Uri.parse(url))
.setDynamicLinkDomain("fmu3k.app.goo.gl")
.setAndroidParameters(
new DynamicLink.AndroidParameters.Builder("io.funswitch.funrooster")
.setMinimumVersion(5)
.build())
.buildShortDynamicLink()
.addOnSuccessListener(shortDynamicLink -> {
mInvitationUrl = shortDynamicLink.getShortLink();
mDatabase.child("Name").addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
String referrerName = dataSnapshot.getValue(String.class);
String subject = String.format("%s wants you to play MyExampleGame!", referrerName);
String invitationLink = mInvitationUrl.toString();
String msg = "Let's play MyExampleGame together! Use my referrer link: "
+ invitationLink;
String msgHtml = String.format("<p>Let's play MyExampleGame together! Use my "
+ "<a href=\"%s\">referrer link</a>!</p>", invitationLink);
Intent intent = new Intent(Intent.ACTION_SENDTO);
intent.setData(Uri.parse("mailto:")); // only email apps should handle this
intent.putExtra(Intent.EXTRA_SUBJECT, subject);
intent.putExtra(Intent.EXTRA_TEXT, msg);
intent.putExtra(Intent.EXTRA_HTML_TEXT, msgHtml);
if (intent.resolveActivity(getActivity().getPackageManager()) != null) {
startActivity(intent);
}
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
});
}
我正在尝试创建一个动态 link,当我尝试调试代码时,它正在调用回调方法 addOnSuccessListener 但之后它没有调用,或者我们说它正在跳过 onSuccess() 方法,我我不知道为什么会这样。
private void firebaseInvite() {
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
String uid = user.getUid();
String url = "https://larky.funswitch.io/?invitedby=" + uid;
FirebaseDynamicLinks.getInstance().createDynamicLink()
.setLink(Uri.parse(url))
.setDynamicLinkDomain("https://fmu3k.app.goo.gl")
.setAndroidParameters(
new DynamicLink.AndroidParameters.Builder("io.funswitch.funrooster")
.setMinimumVersion(5)
.build())
.buildShortDynamicLink()
.addOnSuccessListener(shortDynamicLink -> {
在此之后我的调试器跳过这段代码并且它没有调用
mInvitationUrl = shortDynamicLink.getShortLink();
mDatabase.child("Name").addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
String referrerName = dataSnapshot.getValue(String.class);
String subject = String.format("%s wants you to play MyExampleGame!", referrerName);
String invitationLink = mInvitationUrl.toString();
String msg = "Let's play MyExampleGame together! Use my referrer link: "
+ invitationLink;
String msgHtml = String.format("<p>Let's play MyExampleGame together! Use my "
+ "<a href=\"%s\">referrer link</a>!</p>", invitationLink);
Intent intent = new Intent(Intent.ACTION_SENDTO);
intent.setData(Uri.parse("mailto:")); // only email apps should handle this
intent.putExtra(Intent.EXTRA_SUBJECT, subject);
intent.putExtra(Intent.EXTRA_TEXT, msg);
intent.putExtra(Intent.EXTRA_HTML_TEXT, msgHtml);
if (intent.resolveActivity(getActivity().getPackageManager()) != null) {
startActivity(intent);
}
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
});
}
请帮帮我..
我解决了这是一个非常基本的愚蠢错误,我实际上正在做 link 没有在上面的代码中解析,因为我在动态 link 和动态 [=13] 中提到了两次 https =] 域从动态 link 域中删除 https 后我得到它的工作。
private void firebaseInvite() {
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
String uid = user.getUid();
String url = "https://larky.funswitch.io/?invitedby=" + uid;
FirebaseDynamicLinks.getInstance().createDynamicLink()
.setLink(Uri.parse(url))
.setDynamicLinkDomain("fmu3k.app.goo.gl")
.setAndroidParameters(
new DynamicLink.AndroidParameters.Builder("io.funswitch.funrooster")
.setMinimumVersion(5)
.build())
.buildShortDynamicLink()
.addOnSuccessListener(shortDynamicLink -> {
mInvitationUrl = shortDynamicLink.getShortLink();
mDatabase.child("Name").addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
String referrerName = dataSnapshot.getValue(String.class);
String subject = String.format("%s wants you to play MyExampleGame!", referrerName);
String invitationLink = mInvitationUrl.toString();
String msg = "Let's play MyExampleGame together! Use my referrer link: "
+ invitationLink;
String msgHtml = String.format("<p>Let's play MyExampleGame together! Use my "
+ "<a href=\"%s\">referrer link</a>!</p>", invitationLink);
Intent intent = new Intent(Intent.ACTION_SENDTO);
intent.setData(Uri.parse("mailto:")); // only email apps should handle this
intent.putExtra(Intent.EXTRA_SUBJECT, subject);
intent.putExtra(Intent.EXTRA_TEXT, msg);
intent.putExtra(Intent.EXTRA_HTML_TEXT, msgHtml);
if (intent.resolveActivity(getActivity().getPackageManager()) != null) {
startActivity(intent);
}
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
});
}