Android如何在Android 6.0中无需选择器对话框发送图像

时间:2015-12-23 06:05:30

标签: android android-intent android-activity android-keypad

我有自定义键盘可以将图像分享到任何应用程序。下面的代码在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);

0 个答案:

没有答案