2014-09-26 58 views
0

我想在facebook上发布文字而不使用facebook sdk。Android发布状态意图

我已经知道怎样才能与Facebook

Intent intent = new Intent(Intent.ACTION_SEND); 
     intent.setType("text/plain"); 
// intent.putExtra(Intent.EXTRA_SUBJECT, "Foo bar"); // NB: has no effect! 
     intent.putExtra(Intent.EXTRA_TEXT, urlToShare); 

// See if official Facebook app is found 
     boolean facebookAppFound = false; 
     List<ResolveInfo> matches = getActivity().getPackageManager().queryIntentActivities(intent, 0); 
     for (ResolveInfo info : matches) { 
      if (info.activityInfo.packageName.toLowerCase().startsWith("com.facebook.katana")) { 
       intent.setPackage(info.activityInfo.packageName); 
       facebookAppFound = true; 
       break; 
      } 
     } 

// As fallback, launch sharer.php in a browser 
     if (!facebookAppFound) { 
      String sharerUrl = "https://www.facebook.com/sharer/sharer.php?u=" + urlToShare; 
      intent = new Intent(Intent.ACTION_VIEW, Uri.parse(sharerUrl)); 
     } 

     startActivity(intent); 
    } 

我想要做相同,但与简单的文本链接分享.. 我能做些什么?

+0

通过简单的文字,你的意思是? – Pavlos 2014-09-26 14:33:49

+0

@Pavlos我的意思是纯文本,而不是URL。 – 2014-09-26 14:34:50

回答

1

我认为你不能这样做!我看看下面的链接,因为它说这是一个知道的错误,而Facebook似乎并不在意修复它。 Android and Facebook share intent

+0

但是,通过facebook SDK我可以分享一个简单的文本? (这意味着发布文字) – 2014-09-26 14:47:39

+0

使用Facebook SDK,您可以做任何事情! – Pavlos 2014-09-26 14:51:46