我有这一行,我分享了“要分享的文字”
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, "text to share");
sendIntent.setType("text/plain");
startActivity(sendIntent);
但我想分享一个@string no“text to share”
答案 0 :(得分:1)
您可以使用getResources()
方法访问您的资源,然后使用getString()
:
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, getResources().getString(R.string.text_to_share));
sendIntent.setType("text/plain");
startActivity(sendIntent);