2012-04-27 45 views
0

首先,我的應用程序的功能是閱讀文章。當用戶閱讀文章並且他想將文章分享給Facebook或其他人時,我無法從類型中找到鏈接/超鏈接。如何分享Facebook,Twitter等鏈接?

這裏是我的共享功能

private void shareIt() { 
    Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND); 
    sharingIntent.setType("text/plain"); 
    String shareBody = "Here is the share content body"; 
    sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Subject Here"); 
    sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareBody); 
    startActivity(Intent.createChooser(sharingIntent, "Share via")); 
} 

,我想是分享功能使用計算機時,閱讀文章,並得到了分享按鈕的事情。在共享媒體中,它將顯示爲文章的內容而不是純文本。

那麼,如何編輯代碼以便我可以共享鏈接?

請指導我的Manifest.xml,我不知道interfilter需要增加哪一類了。

其次,我看到因爲我想這些那些的Facebook,新浪網,微博,而不是谷歌,Gmail,藍牙線或消息的共享列表,內置的名單不是對我這麼好。

那麼,如何實現通過Java共享列表?

回答

0

這可能是這樣的

sharebtn = new Custom_ButtonField(share, shareactive, shareactive) { 
      protected boolean navigationClick(int status, int time) { 
       if (Config_GlobalFunction.isConnected()) { 
        String NEXT_URL = "http://www.facebook.com/connect/login_success.html"; 
        String APPLICATION_ID = "153555168010272"; 
        String APPLICATION_SECRET = "354f91a79c8fe5a8de9d65b55ef9aa1b"; 
        String[] PERMISSIONS = Facebook.Permissions.USER_DATA_PERMISSIONS; 
        ApplicationSettings as = new ApplicationSettings(
          NEXT_URL, APPLICATION_ID, APPLICATION_SECRET, 
          PERMISSIONS); 
        Facebook fb = Facebook.getInstance(as); 
        try { 
         User user = fb.getCurrentUser(); 
         user.publishStatus(Config_GlobalFunction.sharelink 
           + newsid); 
        } catch (FacebookException e) { 
        } 
       } else 
        Config_GlobalFunction.Message(
          Config_GlobalFunction.nosharenews, 1); 
       return true; 
      } 
     }; 
     add(sharebtn); 

前提條件:必須導入BB的Facebook SDK。