Advertisement
Guest User

Untitled

a guest
Sep 3rd, 2014
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.41 KB | None | 0 0
  1. ArrayList<String> list = new ArrayList();
  2. list.add("http://example.url:8000/uploads/images1.jpg");
  3. list.add("http://example.url:8000/uploads/images2.jpg");
  4. list.add("http://example.url:8000/uploads/images3.jpg");
  5. int index = 0;
  6. RequestBatch reqBatch = new RequestBatch();
  7. do {
  8. Bundle postParams = new Bundle();
  9. postParams.putString("picture", list.get(index).toString());
  10. postParams.putString("message", "message");
  11. Request request = new Request(Session.getActiveSession(),"group_id/feed", postParams, HttpMethod.POST);
  12. request.setCallback( new Request.Callback() {
  13. @Override
  14. public void onCompleted(Response response) {
  15. Log.d(TAG, ""+response);
  16. }
  17. });
  18. reqBatch.add(request);
  19. index++;
  20. }while(list.size()>index);
  21. reqBatch.executeAsync();
  22.  
  23. Bundle params = new Bundle();
  24. params.putString("name", "name");
  25. params.putString("caption", "caption");
  26. params.putString("description", "TEST");
  27. params.putString("link", "http://image.url/image.jpg");
  28. params.putString("to", "group_id"); // how to change to group wall???? and how to set 2+ photos???
  29.  
  30. WebDialog feedDialog = (
  31. new WebDialog.FeedDialogBuilder(this,
  32. Session.getActiveSession(),params)).setOnCompleteListener(new OnCompleteListener() {
  33.  
  34. @Override
  35. public void onComplete(Bundle values, FacebookException error) {
  36. // TODO Auto-generated method stub
  37. Log.d(TAG, values.toString());
  38. }
  39.  
  40. })
  41. .build();
  42. feedDialog.show();
  43.  
  44. protected void share(String nameApp, String imagePath, String text) {
  45. // TODO Auto-generated method stub
  46.  
  47. try {
  48. List<Intent> targetedShareIntents = new ArrayList<Intent>();
  49. Intent share = new Intent(android.content.Intent.ACTION_SEND_MULTIPLE);
  50. share.setType("image/jpeg");
  51. List<ResolveInfo> resInfo = getActivity().getPackageManager()
  52. .queryIntentActivities(share, 0);
  53. if (!resInfo.isEmpty()) {
  54. for (ResolveInfo info : resInfo) {
  55. Intent targetedShare = new Intent(
  56. android.content.Intent.ACTION_SEND_MULTIPLE);
  57. targetedShare.setType("image/png"); // put here your mime
  58. // type
  59. if (info.activityInfo.packageName.toLowerCase().contains(
  60. nameApp)
  61. || info.activityInfo.name.toLowerCase().contains(
  62. nameApp)) {
  63. targetedShare.putExtra(Intent.EXTRA_SUBJECT, text);
  64. targetedShare.putExtra(Intent.EXTRA_TEXT, text);
  65. ArrayList<Uri> files = new ArrayList<Uri>();
  66. for(int j= 0;j<caminhos.size();j++){
  67. if(!caminhos.get(j).isEmpty()){
  68. File file = new File(caminhos.get(j));
  69. Uri uri = Uri.fromFile(file);
  70. files.add(uri);
  71. }
  72. }
  73.  
  74. targetedShare.putParcelableArrayListExtra(Intent.EXTRA_STREAM,
  75. files);
  76. targetedShare.setPackage(info.activityInfo.packageName);
  77. targetedShareIntents.add(targetedShare);
  78. }
  79. }
  80. Intent chooserIntent = Intent.createChooser(
  81. targetedShareIntents.remove(0), "Select app to share");
  82. chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS,
  83. targetedShareIntents.toArray(new Parcelable[] {}));
  84. startActivity(chooserIntent);
  85. }
  86. } catch (Exception e) {
  87. }
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement