2012-08-09 47 views
2

我需要Google+中的分享链接。在文档中,我看到了以下代码:在Google+上分享

Button shareButton = (Button) findViewById(R.id.share_button); 
shareButton.setOnClickListener(new OnClickListener() 
{ 
    @Override 
    public void onClick(View v) 
    { 
     // Launch the Google+ share dialog with attribution. 
     Intent shareIntent = ShareCompat.IntentBuilder.from(ExampleActivity.this) 
      .setType("text/plain") 
      .setText("Welcome to the Google+ platform. https://developers.google.com/+") 
      .getIntent() 
      .setPackage("com.google.android.apps.plus"); 

     startActivity(shareIntent); 
    } 
}); 

但是,如果在我的手机上是官方客户端Google+,它将起作用。我可以在Google+中分享链接,而无需使用官方客户端。

+0

是的,但你必须有谷歌+ API。 – Gorets 2012-08-09 11:54:45

+0

我没有找到它是怎么回事的:(。 – Vladimir 2012-08-09 11:56:57

+0

http://code.google.com/p/google-api-java-client/wiki/APIs#Google+_API – Gorets 2012-08-09 12:00:42

回答

0

共享意图,显示在您提供的代码中。使用原生的Google+应用程序将内容分享到Google+。这是在Android上将内容分享到Google+的唯一方式。