撰写推文图片未加载?

Compose Tweets Picture Not Loading?

所以我一直在关注这个 link 从我正在创建的应用程序撰写推文:https://dev.twitter.com/twitter-kit/android/compose

现在我在 Android Studio 中测试它时没有收到任何错误,但在我的 phone 上,当我按下按钮时一切正常,除了它 "couldn't load the picture"。文件路径可能有一个简单的修复,但我似乎无法弄清楚。

这是代码。

public void onClickShareTwitter(View view) {
    File myImageFile = new File("/drawable/logo.png");
    Uri myImageUri = Uri.fromFile(myImageFile);
    TweetComposer.Builder builder = new TweetComposer.Builder(this)
            .text("My BMI is " + BMIMessage + ". I used the Application BMI Calculator By Dan Andersson #android")
            .image(myImageUri);

    builder.show();

提前致谢。

试一试:

private Uri getResourceUri(Resources resources, int resourceId)
{
    return Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://" +
            resources.getResourcePackageName(resourceId) + '/' +
            resources.getResourceTypeName(resourceId) + '/' +
            resources.getResourceEntryName(resourceId));
}

...

Uri myImageUri = getResourceUri(getResources(), R.drawable.logo);