当我尝试在桌面上设置壁纸时,我收到此消息。为什么?以及如何删除此消息?
我的代码: - 点击按钮:
Intent intent = new Intent();
intent.setAction(Intent.ACTION_ATTACH_DATA);
intent.addCategory(Intent.CATEGORY_DEFAULT);
intent.setDataAndType(ContactsContract.Contacts.CONTENT_URI, "image/*");
intent.putExtra("mimeType", "image/*");
startActivityForResult(Intent.createChooser(intent, "Select service:"), position);
然后onActivityResult:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
resultView.setDrawingCacheEnabled(true);
Bitmap bitmap = resultView.getDrawingCache();
new TaskSetWallpaper(GalleryActivity.this).execute(bitmap);
}
和设置壁纸的内部类:
public class TaskSetWallpaper extends AsyncTask<Bitmap, Void, Bitmap>
{
private Context context;
private ProgressDialog pDialog;
TaskSetWallpaper(Context context)
{
this.context = context;
}
@Override
protected void onPreExecute()
{
super.onPreExecute();
pDialog = new ProgressDialog(context);
CharSequence text = getText(R.string.crop__wait);
pDialog.setMessage(text);
pDialog.setIndeterminate(false);
pDialog.setCancelable(false);
pDialog.show();
}
@Override
protected Bitmap doInBackground(Bitmap... bitmaps)
{
WallpaperManager wallpaperManager = WallpaperManager.getInstance(getApplicationContext());
try
{
wallpaperManager.setBitmap(bitmaps[0]);
} catch (IOException e)
{
e.getMessage();
}
return null;
}
@Override
protected void onPostExecute(Bitmap bitmap)
{
super.onPostExecute(bitmap);
pDialog.dismiss();
CharSequence text = getText(R.string.set_wlp_toast);
Toast toast = Toast.makeText(context, text, Toast.LENGTH_SHORT);
toast.setGravity(Gravity.CENTER, 0, 0);
toast.show();
}
}
请给我建议
已编辑,添加日志:
04-26 12:40:20.687 18396-18396/com.nico.testwalpapers W/System: ClassLoader referenced unknown path: /data/app/com.nico.testwalpapers-2/lib/arm
04-26 12:40:20.691 18396-18396/com.nico.testwalpapers I/InstantRun: starting instant run server: is main process
04-26 12:40:20.796 18396-18396/com.nico.testwalpapers W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
04-26 12:40:20.997 18396-18467/com.nico.testwalpapers D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
04-26 12:40:21.082 18396-18396/com.nico.testwalpapers W/Settings: Setting airplane_mode_on has moved from android.provider.Settings.System to android.provider.Settings.Global, returning read-only value.
04-26 12:40:21.124 18396-18467/com.nico.testwalpapers I/Adreno-EGL: <qeglDrvAPI_eglInitialize:379>: QUALCOMM Build: 10/21/15, 369a2ea, I96aee987eb
04-26 12:40:21.130 18396-18467/com.nico.testwalpapers I/OpenGLRenderer: Initialized EGL, version 1.4
04-26 12:40:21.200 18396-18396/com.nico.testwalpapers W/art: Before Android 4.1, method int android.support.v7.widget.ListViewCompat.lookForSelectablePosition(int, boolean) would have incorrectly overridden the package-private method in android.widget.ListView
04-26 12:41:15.491 18396-18396/com.nico.testwalpapers D/GalleryActivity: **onCreate
04-26 12:41:23.033 18396-18396/com.nico.testwalpapers D/GalleryActivity: **click tp set wallpaper button
04-26 12:41:27.681 18396-18396/com.nico.testwalpapers D/GalleryActivity: **onPreExecute
04-26 12:41:27.741 18396-19626/com.nico.testwalpapers D/GalleryActivity: **doInBackground
04-26 12:41:28.491 18396-18396/com.nico.testwalpapers D/GalleryActivity: **onPostExecute
答案 0 :(得分:4)
试试这可能对你有用。 我通过以下解决方案解决了这个问题:
Intent intent = new Intent("com.android.camera.action.CROP");
//add below two line
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);