谷歌加从Android应用程序共享 [英] Google Plus sharing from android app

查看:136
本文介绍了谷歌加从Android应用程序共享的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在试图张贴在晨起谷歌加流,但它并没有得到张贴在只有deeplinkid里面的内容的setText规定的所有内容()被公布。 这里是我的code,

 意图shareIntent =新PlusShare.Builder(本)
                    .setText(你好Android的!)
                    .setType(图像/ PNG)
                    .setContentDeepLinkId(offrdetails_data.get(0).offerLink,
                            offrdetails_data.get(0).dealTitle,
                            offrdetails_data.get(0).dealDescription,
                            Uri.parse(offrdetails_data.get(0).dealImage))
                    .getIntent();
startActivityForResult(shareIntent,0);
 

解决方案

我只是测试你的code以最小的MainActivity和它的工作:

 公共类MainActivity扩展活动实现View.OnClickListener {

私人按钮mButton;

@覆盖
保护无效的onCreate(包savedInstanceState){
    super.onCreate(savedInstanceState);
    的setContentView(R.layout.activity_main);

    mButton =(按钮)findViewById(R.id.button1);
    mButton.setOnClickListener(本);
}

@覆盖
公共布尔onCreateOptionsMenu(功能菜单){
    //充气菜单;这增加了项目操作栏,如果它是present。
    。getMenuInflater()膨胀(R.menu.main,菜单);
    返回true;
}

@覆盖
公共无效的onClick(视图v){
    意图shareIntent =新PlusShare.Builder(本)
            .setText(你好Android的!)
            .setType(图像/ PNG)
            .setContentDeepLinkId(testID
                    测试名称,
                    考试说明,
                    Uri.parse(https://developers.google.com/+/images/interactive-post-android.png))
            .getIntent();
    startActivityForResult(shareIntent,0);
}

}
 

您确定 offrdetails_data.get(0)实际上包含了数据吗?

响应于注释编辑:这可能是offrdetails_data.get(0).offerLink长于512个字符

在深度链接ID的限制为512个字符(参见说明数据calltoactiondeeplinkid):

https://developers.google.com/+/web/share/interactive#interactive_share_button_attributes

I have been trying to post on google plus stream since morning, but it does not getting posted all contents specified in deeplinkid only the content inside setText() gets posted. here is my code,

  Intent shareIntent = new PlusShare.Builder(this)
                    .setText("Hello Android!")
                    .setType("image/png")
                    .setContentDeepLinkId(offrdetails_data.get(0).offerLink,
                            offrdetails_data.get(0).dealTitle, 
                            offrdetails_data.get(0).dealDescription, 
                            Uri.parse(offrdetails_data.get(0).dealImage))
                    .getIntent();
startActivityForResult(shareIntent, 0);

解决方案

I just tested your code with a minimal MainActivity and it worked:

public class MainActivity extends Activity implements View.OnClickListener {

private Button mButton;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mButton = (Button) findViewById(R.id.button1);
    mButton.setOnClickListener(this);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

@Override
public void onClick(View v) {
    Intent shareIntent = new PlusShare.Builder(this)
            .setText("Hello Android!")
            .setType("image/png")
            .setContentDeepLinkId("testID",
                    "Test Title",
                    "Test Description",
                    Uri.parse("https://developers.google.com/+/images/interactive-post-android.png"))
            .getIntent();
    startActivityForResult(shareIntent, 0);
}

}

Are you sure that offrdetails_data.get(0) actually contains data?

Edit in response to comments: It may be that offrdetails_data.get(0).offerLink is longer than 512 characters.

The limit on deep link IDs is 512 characters (see description for data-calltoactiondeeplinkid):

https://developers.google.com/+/web/share/interactive#interactive_share_button_attributes

这篇关于谷歌加从Android应用程序共享的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆