android - Sharing only to google plus without photo -
i fount many example can share image installed android app this:
shareintent = sharecompat.intentbuilder .from(getactivity()) .settype("image/*") .setstream(imageuris.get(0)) .getintent() .setpackage("com.google.android.apps.plus"); startactivity(shareintent); but when that, see complete action using selection: link
which unacceptable fro app. want share in goole plus. real share without google.photos? solution find code:
intent shareintent = new intent(); shareintent .setaction(imageuris.size() > 1 ? intent.action_send_multiple : intent.action_send); shareintent.putparcelablearraylistextra(intent.extra_stream, imageuris); shareintent.settype("image/*"); packagemanager pm = context.getpackagemanager(); intent sendintent = new intent(intent.action_send); sendintent.setaction(imageuris.size() > 1 ? intent.action_send_multiple : intent.action_send); sendintent.settype("image/*"); list<resolveinfo> resinfo = pm.queryintentactivities(sendintent, 0); list<labeledintent> intentlist = new arraylist<labeledintent>(); (int = 0; < resinfo.size(); i++) { resolveinfo ri = resinfo.get(i); string packagename = ri.activityinfo.packagename; if (packagename.equals("com.facebook.katana")) { shareintent.setpackage(packagename); log.e("new", "count 0"); } else if (packagename.equals("com.google.android.apps.plus") || (packagename .equals("com.yahoo.mobile.client.android.flickr") || packagename .equals("com.twitter.android"))) { intent intent = new intent(); intent.setcomponent(new componentname(packagename, ri.activityinfo.name)); intent.setaction(imageuris.size() > 1 ? intent.action_send_multiple : intent.action_send); intent.settype("image/*"); if (packagename.equals("com.google.android.apps.plus")) { intent.putparcelablearraylistextra(intent.extra_stream, imageuris); } else if (packagename .equals("com.yahoo.mobile.client.android.flickr")) { intent.putparcelablearraylistextra(intent.extra_stream, imageuris); } else if (packagename.equals("com.twitter.android")) { intent.putparcelablearraylistextra(intent.extra_stream, imageuris); } intentlist.add(new labeledintent(intent, packagename, ri .loadlabel(pm), ri.icon)); } } // removing google photos in ios (int = 0; < intentlist.size(); i++) { string = intentlist.get(i).getcomponent().getclassname(); if (a.contains("com.google.android.apps.photos")) { intentlist.remove(i); } } // convert intentlist array labeledintent[] extraintents = intentlist .toarray(new labeledintent[intentlist.size()]); intent openinchooser = intent.createchooser(shareintent, string.format( context.getstring(r.string.format_share_photos), imageuris.size())); openinchooser.putextra(intent.extra_initial_intents, extraintents); context.startactivity(openinchooser); but can share image (or images) facebook , can share image of intentlist. body me or answer question. in advance
answer is:
intent shareintent = null; try { if (imageuris.size() > 1) { shareintent = new intent(); shareintent.setaction(intent.action_send_multiple); shareintent.putparcelablearraylistextra( intent.extra_stream, imageuris); shareintent.settype("image/*"); shareintent.setclassname("com.google.android.apps.plus", "com.google.android.libraries.social.gateway.gatewayactivity"); startactivity(shareintent); } else { shareintent = sharecompat.intentbuilder .from(getactivity()) .settype("image/*") .setstream(imageuris.get(0)) .getintent() .setclassname("com.google.android.apps.plus", "com.google.android.libraries.social.gateway.gatewayactivity"); startactivity(shareintent); } } catch (activitynotfoundexception e) { startactivity(new intent(intent.action_view, uri.parse("https://plus.google.com/" + "profile" + "/posts"))); } break;
Comments
Post a Comment