我尝试使用他的用户ID以编程方式为特定用户打开Facebook Messenger。
这是我的代码:
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(mContext);
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
android.view.View dialogView = inflater.inflate(R.layout.dialog_right_swipe, null);
dialogBuilder.setView(dialogView);
TextView contactForBuyingTxt = dialogView.findViewById(R.id.contact_for_buying_txt);
contactForBuyingTxt.setText("Would you like to contact " + mProfile.getPosterName() + " for buying this product?");
dialogBuilder.setPositiveButton("YES", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("fb-messenger://user/"+mProfile.getPosterID()));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mContext.startActivity(intent);
}
});
dialogBuilder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
//pass
}
});
AlertDialog b = dialogBuilder.create();
b.show();
这里有Profile.java:
public class Profile {
public Profile() {
}
@SerializedName("imageUrl")
@Expose
private ArrayList<String> imageUrl;
@SerializedName("pDescription")
@Expose
private String pDescription;
@SerializedName("pUsedDuration")
@Expose
private String pUsedDuration;
@SerializedName("pPrice")
@Expose
private String pPrice;
@SerializedName("postedAt")
@Expose
private String postedAt;
@SerializedName("pName")
@Expose
private String pName;
@SerializedName("pImage")
@Expose
private String pImage;
@SerializedName("pID")
@Expose
private String pID;
@SerializedName("listingID")
@Expose
private String listingID;
public Profile(ArrayList<String> pImageUrl, String pDescription, String pDuration, String pPrice, String postedAt, String pName, String pUrl, String pID, String listingID) {
this.imageUrl = pImageUrl;
this.pDescription = pDescription;
this.pDuration = pDuration;
this.pPrice = pPrice;
this.postedAt = postedAt;
this.pName = pName;
this.pImage = pImageUrl;
this.pID = pID;
this.listingID = listingID;
}
public String getPDescription() {
return pDescription;
}
public void setPDescription(String pDescription) {
this.pDescription = pDescription;
}
public ArrayList<String> getImageUrl() {
return imageUrl;
}
public void setImageUrl(ArrayList<String> imageUrl) {
this.imageUrl = imageUrl;
}
public String getPDuration() {
return pDuration;
}
public void setPDuration(String pDuration) {
this.pDuration = pDuration;
}
public String getPPrice() {
return pPrice;
}
public void setPPrice(String pPrice) {
this.pPrice = pPrice;
}
public String getPostedAt() {
return postedAt;
}
public void setPostedAt(String postedAt) {
this.postedAt = postedAt;
}
public String getPName() {
return pName;
}
public void setPName(String pName) {
this.pName = pName;
}
public String getPImage() {
return pImage;
}
public void setPImage(String pImage) {
this.pImage = pImage;
}
public String getPID() {
return pID;
}
public void setPID(String pID) {
this.pID = pID;
}
public String getListingID() {
return listingID;
}
public void setListingID(String listingID) {
this.listingID = listingID;
}
}
请考虑一下:有不同的商家信息,其中mProfile.getPosterName()
是发布商家信息的人的名字,mProfile.getPosterId()
是他的朋友ID。
这是打开聊天头,但不是为特定用户打开它,而是聊天头显示“Facebook用户&#39;作为名字。
AccessToken.getCurrentAccessToken().getUserId()
一个看起来像这样:
1493******22153
和findmyfbid.com看起来像这样:
1000******00783
为什么会发生这种情况,请告诉我如何为特定用户打开聊天记录?