2013-08-22 46 views

回答

0

Google+應用是否安裝或沒有在您的設備,以便嘗試它應該對你有所幫助......

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; 
    } 
} 
    }); 
}