问题
i have try to post Image from server and link URL both in google plus from android application.. but i can't post both in google plus..
i have try this code to post..
Intent shareIntent = new
PlusShare.Builder(GooglePlusActivity.this)
.setType("text/plain")
.setText("Welcome to the Google+ platform....")
.setContentDeepLinkId("/cheesecake/lemon",
"Lemon Cheesecake recipe",
"A tasty recipe for making lemon cheesecake.",
Uri.parse("http://www.onedigital.mx/ww3/wp-content/uploads/2012/02/android-420x315.jpg"))
.setContentUrl(Uri.parse("https://developers.google.com/+/"))
.getIntent();`
In tthis code i have only post a image but not post URL.. URl is display but it not clickable.
some one give me solution for my problem..
回答1:
You need google-play-services_lib
library project. Just import it in workspace in add in your project.
You can find it at .../android-sdk-linux_x86/extras/google/google_play_services/libproject
And use this code for sharing on google-plus via google-plus application.
final int errorCode = GooglePlusUtil.checkGooglePlusApp(mActivity);
if (errorCode == GooglePlusUtil.SUCCESS) {
// Invoke the ACTION_SEND intent to share to Google+ with attribution.
Intent shareIntent = ShareCompat.IntentBuilder.from(mActivity)
.setText("")
.setType("text/plain")
.getIntent()
.setPackage("com.google.android.apps.plus");
startActivity(shareIntent);
} else {
Toast.makeText(mActivity, "Google plus not installed", Toast.LENGTH_LONG).show();
}
回答2:
The solution is to share an image and give the URL in the accompanying text. See the PlusShare documentation:
https://developers.google.com/+/mobile/android/share/media
It says: When you share media to Google+, you cannot also use the setContentUrl method. If you want to include a URL in the post with the media, you should append the URL to the prefilled text in the setText() method.
回答3:
Add your media url with text message in .setText field
Intent shareIntent = ShareCompat.IntentBuilder.from(activity) .setType("text/plain") .setText("Sharing text with image link \n "+***url***) .setStream(null) .getIntent() .setPackage("com.google.android.apps.plus"); activity.startActivity(shareIntent);
来源:https://stackoverflow.com/questions/18288099/how-post-image-and-link-url-in-google-plus-from-android-application