我有自定义键盘可以将图像分享到任何应用程序。下面的代码在Andron 4.4和5.1中完美运行,但在6.0中无法共享图像。
//get package name of current running application.
ActivityManager mActivityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
packageName = mActivityManager.getRunningAppProcesses().get(1).processName;
//Sending image to running application
String s = arrPhoto.get(position).getImagName();
File F = new File( Environment.getExternalStorageDirectory()+"/My Image/"+s);
Uri U = Uri.fromFile(F);
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("image/png");
i.putExtra(Intent.EXTRA_STREAM, U);
i.setPackage(packageName);
startActivity(i);