0

我正在尝试使用他的用户 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()他的 facebook id。

这是打开聊天头,但不是为特定用户打开它,而是聊天头显示“Facebook 用户”作为名称。

AccessToken.getCurrentAccessToken().getUserId()一个看起来像这样:

1493******22153

findmyfbid.com 看起来像这样:

1000******00783

为什么会发生这种情况,请告诉我如何为特定用户打开聊天头?

4

0 回答 0