我使用下面的代码,但仅在我的真实设备api23 nexus5上部分工作,而在其他设备上无法设置。也不能为联系人图标设置壁纸。
我的操作:
- 点击设置壁纸按钮 - 在打开的窗口中选择服务:
如果选择“联系人照片” - 打开该服务并选择任何一个联系人。
实际结果:只是返回到我的壁纸应用程序而没有进行设置。
期望结果:必须打开“裁剪图片”图像,然后点击将此图像设置为联系人图标。
如果选择“壁纸”
我的操作:
- 点击设置壁纸按钮 - 在打开的窗口中选择服务:
如果选择“联系人照片” - 打开该服务并选择任何一个联系人。
实际结果:只是返回到我的壁纸应用程序而没有进行设置。
期望结果:必须打开“裁剪图片”图像,然后点击将此图像设置为联系人图标。
如果选择“壁纸”
- Actual reuslt: just return to my wallpapers app without set and show message 'Can not load the image'(work only api 23 on my Nexus5)
Expected result: open the service and tap to set
Intent intent = new Intent(Intent.ACTION_ATTACH_DATA); // attach services intent.addCategory(Intent.CATEGORY_DEFAULT); file = new File(getFolderStorageDirectory(), getFileName()); // create temp file if (isExternalStorageWritable()) { // check whether available external storage try { FileOutputStream out = new FileOutputStream(file); mBitmap.compress(Bitmap.CompressFormat.JPEG, 100, out); // write image out.flush(); out.close(); } catch (Exception e) { e.printStackTrace(); Log.e(TAG, "File not saved"); } } else { showToast(getString(R.string.sd_card)); } intent.setDataAndType(Uri.parse(file.getAbsolutePath()), "image/*"); intent.putExtra("mimeType", "image/*"); intent.putExtra("jpg", "image/*"); intent.putExtra(Intent.EXTRA_STREAM, Uri.parse(file.getAbsolutePath())); startActivity(Intent.createChooser(intent, "Select service:"));