Android app card sharing not working

android
cards

#1

Hello, I want to share my application content on android. First i download picture, then I use your code from documentation, but I could not see app card image. After clicking on tweet, tweeting activity is closed with error:

Post Tweet failed
com.twitter.sdk.android.core.TwitterException: Uri file path resolved to null

here’s my code:
final TwitterSession session = TwitterCore.getInstance().getSessionManager().getActiveSession();
Uri uri = Uri.parse(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES) + “be_reporter_twitter_share.jpg”);
Log.d(“twitter”, uri.toString());
final Card card = new Card.AppCardBuilder(getActivity())
.imageUri(uri)
.googlePlayId(“sk.euroap.bereporter”)
.iPhoneId(“1146795924”)
.iPadId(“1146795924”)
.build();
final Intent intent = new ComposerActivity.Builder(getActivity())
.session(session)
.card(card)
.createIntent();
startActivity(intent);


#2

Hey @stefiix92,

Based on the error you posted, the URI isn’t returning a valid file path so I’d check the path that you’re logging out. From another post here, you can see some other solutions and test cases: Unity Fabric AppCard not rendering

-Mike


#3

This will not generate a valid Uri since the toString method of File doesn’t returns a Uri.

Uri uri = Uri.parse(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES) + "be_reporter_twitter_share.jpg");

Try something like:

final File file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "be_reporter_twitter_share.jpg");
final Uri uri = file.toURI();

#4

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.