您可以发布这样的消息..无论您的手机中是否安装了 G+ 应用程序,都可以尝试,这对我有用
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
shareMediaButton = (Button) findViewById(R.id.share_button);
shareMediaButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if(isGooglePlusInstalled())
{
PlusShare.Builder share = new PlusShare.Builder(MainActivity.this);
share.setText("write your message here.....!");
//share.addStream(selectedImage);
share.setType("text/plain");
startActivityForResult(share.getIntent(), 0);
}else{
Intent shareIntent = new PlusShare.Builder(MainActivity.this)
.setType("text/plain")
.setText("write your message here.....!")
.getIntent();
startActivityForResult(shareIntent, 0);
}
}
public boolean isGooglePlusInstalled()
{
try
{
getPackageManager().getApplicationInfo("com.google.android.apps.plus", 0 );
return true;
}
catch(PackageManager.NameNotFoundException e)
{
return false;
}
}
});
}