簡體   English   中英

從Android分享到Google+

[英]Sharing to Google+ from Android

Google+是否支持從Android應用共享? 我想知道,因為我已經在我的應用程序中為twitter和facebook實現了此功能,並且希望對Google+也是如此。 我確實讀過他們現在有一個API,但這僅用於開發和測試,並且無法發布應用。 這個對嗎?

例如,在您的XML中:

<Button
  android:id="@+id/share_button"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:text="Share on 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 to your app.
      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);
    }
});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM