0

2 つの文字列を含むオブジェクト MyObject があります

public class MyObject{ 

    String title
    String description
}

このオブジェクトを次のプラットフォーム (SMS、電子メール、Facebook) で共有したい

だから私のコードは

public String getMySharingStringViaSMS(){

    return title + "\r\n" + description
}

public String getMySharingStringViaEMAIL(){

    return title + "<br />" + description
}

(\r\n) と (br) の両方が Facebook で機能しなかった問題

すべてを処理するメソッドを 1 つだけ作成するにはどうすればよいですか

4

1 に答える 1

0

Facebook でいくつかのものを共有するには、FacebookSdk 3.0 を実装する必要があります。このチュートリアルに従ってください: http://www.kpbird.com/2013/03/android-login-using-facebook-sdk-30.html

主な目標は、facebook を介して「ログイン」を提供し、壁で何かを共有することです。ログインが機能したら、次の方法を試してください。

private void publishStory(String hash, String title, String user) {

Session session = Session.getActiveSession();

if (session != null){
    // Check for publish permissions    
    List<String> permissions = session.getPermissions();
    if (!isSubsetOf(PERMISSIONS, permissions)) {
        pendingPublishReauthorization = true;
        Session.NewPermissionsRequest newPermissionsRequest = new Session
                .NewPermissionsRequest(getActivity(), PERMISSIONS);
        session.requestNewPublishPermissions(newPermissionsRequest);
        return;
    }
    Bundle postParams = new Bundle();
    postParams.putString("name", title);
    postParams.putString("caption", "By Recommend Android");
    postParams.putString("description", user+" "+"STRONGLY recommends"+" "+title);
    postParams.putString("link", "http://re.co/"+hash);
    postParams.putString("picture", "http://re.co/assets/img/useful-exp.png");

    Request.Callback callback= new Request.Callback() {
        public void onCompleted(Response response) {
            JSONObject graphResponse = response
                    .getGraphObject()
                    .getInnerJSONObject();
            String postId = null;
            try {
                postId = graphResponse.getString("id");
            } catch (JSONException e) {
                Log.i(TAG,
                        "JSON error "+ e.getMessage());
            }

次のように、strings.xml で Html タグを宣言する必要があることを忘れないでください。

<string name="demoStr"><Data><![CDATA[ <b>ABC</b><br /> something ]]> </Data></string>

次に getString() が取得されます"<b>ABC</b><br />something"

于 2013-07-02T13:49:46.993 に答える