Android各種機能コード収集
4212 ワード
1.画像などのファイルを単一の指定微信の友达に共有する
2.写真などのファイルを微信のモーメンツに共有する
1 /**
2 * 3 * 4 * @param file 5 * path, file = new File(path); 6 */
7 private void shareToFriend(File file) { 8 Intent intent = new Intent(); 9 ComponentName componentName = new ComponentName("com.tencent.mm", 10 "com.tencent.mm.ui.tools.ShareImgUI"); 11 intent.setComponent(componentName); 12 intent.setAction(Intent.ACTION_SEND); 13 intent.setType("image/*"); 14 intent.putExtra(Intent.EXTRA_TEXT, " "); 15 intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file)); 16 startActivity(intent); 17 }
2.写真などのファイルを微信のモーメンツに共有する
1 /**
2 * 3 * 4 * @param file 5 * , path, file = new File(path); 6 */
7 private void shareToTimeLine(File file) { 8 Intent intent = new Intent(); 9 ComponentName componentName = new ComponentName("com.tencent.mm", 10 "com.tencent.mm.ui.tools.ShareToTimeLineUI"); 11 intent.setComponent(componentName); 12 intent.setAction(Intent.ACTION_SEND); 13 intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file)); 14 intent.setType("image/*"); 15 startActivity(intent); 16 }