mercredi 27 mai 2015

Cannot share images to WeChat and Line using ACTION_SEND intent

My code is as below -

 Intent prototype = new Intent(Intent.ACTION_SEND);
 prototype.setData(uri);   // uri is of the image file
 prototype.setType(image/*);
 prototype.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

 prototype.putExtra(Intent.EXTRA_STREAM, uri); 

List<ResolveInfo> resInfo = pm.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
       if (!resInfo.isEmpty()) 
       { 
           for (ResolveInfo resolveInfo : resInfo) 
            {
                if (resolveInfo.activityInfo == null)  
                {
                    continue; 
                }

                // Retrieve the package name and class name to populate the chooser intent
                Intent intent = (Intent) prototype.clone();
                String packageName = resolveInfo.activityInfo.packageName;
                intent.setPackage(packageName); 
                intent.setClassName(packageName, resolveInfo.activityInfo.name); 
            targetedIntents.add(intent);
        }}
            Intent chooserIntent = Intent.createChooser(topIntents.remove(targetedIntents.size() - 1), chooserTitle); 
                chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, targetedIntents.toArray(new Parcelable[] {})); 

When I select WeChat and Line app from the chooser, nothing happens. Line app just displays an error that it is unable to share. WeChat doesn't give any message. Sharing works fine on Whatsapp and Hangouts using my code.

We can share images on WeChat and Line from Gallery. How does that work? Is it not a Send action intent?

Aucun commentaire:

Enregistrer un commentaire