728x90
반응형
public class EO_Twitter extends Activity{
private static String temp_content;
public static void Twitter_share_T(Context context, String textBody) {
Intent Sharing_intent = new Intent(Intent.ACTION_SEND);
Sharing_intent.setType("text/plain");
Sharing_intent.setPackage("com.twitter.android");
String Test_Message = textBody;
Sharing_intent.putExtra(Intent.EXTRA_TEXT, Test_Message);
Intent Sharing = Intent.createChooser(Sharing_intent, "공유하기");
context.startActivity(Sharing);
}
public static void Twitter_share_TI(Activity activity, String textBody) {
temp_content = textBody;
Intent intent = new Intent(Intent.ACTION_PICK);
intent. setDataAndType(android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*");
activity.startActivityForResult(intent, 200);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 200 && resultCode == RESULT_OK && data != null && data.getData() != null) {
// 이미지 첨부 Twitter_share_TI
Uri selectedImageUri = data.getData();
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.setPackage("com.twitter.android");
intent.putExtra(Intent.EXTRA_TEXT,temp_content);
if (selectedImageUri != null) {
intent.putExtra(Intent.EXTRA_STREAM, selectedImageUri);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.setType("image/*");
}
try {
startActivity(intent);
} catch (android.content.ActivityNotFoundException ex) {
ex.printStackTrace();
}
}
}
}
728x90
반응형
'Android' 카테고리의 다른 글
Android UI BottomSheetDialogFragment (0) | 2021.01.21 |
---|---|
Android 커스텀 다이얼로그 (0) | 2021.01.21 |
Android AAR 만들기 ( 라이브러리 만들기 ) (0) | 2021.01.19 |
Android SNS 공유하기 - facebook (0) | 2021.01.15 |
Android 공유하기 - 네이버 관련 (0) | 2021.01.14 |