Intathep
Intathep

Reputation: 3388

Android : can i attach picture when i tweet via native Twitter app

This is my code

Intent intent = new Intent(Intent.ACTION_SEND);
intent.setClassName("com.twitter.android", "com.twitter.android.PostActivity");
intent.putExtra(Intent.EXTRA_TEXT, message);
startActivity(intent);

can i attach picture programmatically?

enter image description here

EDIT

SOLUTION

1 more line additional

Intent intent = new Intent(Intent.ACTION_SEND);
intent.setClassName("com.twitter.android", "com.twitter.android.PostActivity");
intent.putExtra(Intent.EXTRA_TEXT, message);
intent.putExtra(Intent.EXTRA_STREAM, Uri);      
startActivity(intent);

Upvotes: 3

Views: 1043

Answers (2)

GK_
GK_

Reputation: 1222

Try this Code it works perfectly..if you having twitter application installed in your mobile. otherwise use try..catch

            var postrTwitter = Ti.Android.createIntent({
            action : Ti.Android.ACTION_SEND,
            packageName : "com.twitter.android",
            className : "com.twitter.android.PostActivity",
            flags : Ti.Android.FLAG_ACTIVITY_NEW_TASK,
            type : "text/plain"
            });
            postrTwitter.setType("*/*");
            postrTwitter.putExtra(Ti.Android.EXTRA_TEXT, "Text message ");
            postrTwitter.putExtraUri(Ti.Android.EXTRA_STREAM, image_file.nativePath);

            Ti.Android.currentActivity.startActivity(postrTwitter);

Upvotes: 0

Chirag
Chirag

Reputation: 56935

Try this.

Intent sharingIntent = new Intent(Intent.ACTION_SEND_MULTIPLE);
Uri screenshotUri = Uri.parse("file:///sdcard/image.jpg");
sharingIntent.setType("*/*");
sharingIntent.putExtra(Intent.EXTRA_TEXT, "Body text of the new status");
sharingIntent.putExtra(Intent.EXTRA_STREAM, screenshotUri);
startActivity(Intent.createChooser(sharingIntent, "Share image using"));

Upvotes: 2

Related Questions