You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
엄마가 문자로 온 몇 백장의 사진들을 카카오톡으로 공유하는 일이 필요하게 됐는데 사진을 일일이 다운로드 받아서 공유하는 것이 불편하다고 하여 만들어 봤습니다. SMS 텍스트, MMS 텍스트/사진을 탐색하여 외부로 한번에 공유할 수 있는 안드로이드 앱 입니다.
개발 환경
Android Studio 3.0.1
Kakao SDK (공부할 겸 한 번 사용해봄..실제 쓰이는 건 프로필 사진, 이름)
Version : 1.16.0
Use : usermgmt
필요한 권한
AndroidManifest.xml
<!-- 문자 메시지 읽기 권한 -->
<uses-permission android:name="android.permission.READ_SMS" />
<!-- 인터넷 사용 권한 -->
<uses-permission android:name="android.permission.INTERNET" />
<!-- 외부 저장소 파일 읽기,생성 권한 -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
public void startShareIntent() {
SparseBooleanArray boolArr = listview.getCheckedItemPositions();
String path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES) + File.separator + "mother";
File directory;
ArrayList<Uri> files = new ArrayList<>();
for(int i=0;i<listview.getCheckedItemCount();i++) {
if(boolArr.get(i)){
directory = new File(path,phone+"_"+mmsData.get(i).getId()+".png");
// generate URI, I defined authority as the application ID in the Manifest, the last param is file I want to open
files.add( FileProvider.getUriForFile(this, BuildConfig.APPLICATION_ID, directory) );
}
}
final Intent shareIntent = new Intent(Intent.ACTION_SEND_MULTIPLE);
// set flag to give temporary permission to external app to use your FileProvider
shareIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
shareIntent.putExtra(Intent.EXTRA_STREAM, files);
shareIntent.setType("image/*");
// validate that the device can open your File!
PackageManager pm = getApplicationContext().getPackageManager();
if (shareIntent.resolveActivity(pm) != null) {
startActivity(shareIntent);
}
}