分享文字内容到nexus 5的hangout上

            // At least KitKat, KitKat系统使用的是hangout来分享.
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
                // Need to change the build to API 19
                String defaultSmsPackageName = Telephony.Sms.getDefaultSmsPackage(context);

                Intent sendIntent = new Intent(Intent.ACTION_SEND);
                sendIntent.setType("text/plain");
                // 传递文本内容
                sendIntent.putExtra(Intent.EXTRA_TEXT, "你的文字内容");
                // Can be null in case that there is no default, then the user
                // would be able to choose any app that support this intent.
                if (defaultSmsPackageName != null) {
                    sendIntent.setPackage(defaultSmsPackageName);
                }
             // context, 你懂的.
             context.startActivity(sendIntent);
            }


在nexus 5上测试成功。图片分享没有用到,有需要的自己弄吧。

你可能感兴趣的:(分享文字内容到nexus 5的hangout上)