下载无法在Android棉花糖上使用

问题描述

我正在使用毕加索通过url将图像提取到imageview中,并使用以下代码将图像下移 要注意的是,下载在Android 10中运行正常。另外,我使用的是真实的设备来检查我的应用程序。有什么方法可以检查我的应用程序可能遇到的所有Android版本?

 public void onClick(View view) {
            //asking for permission
         //   askpermission("WRITE_EXTERNAL_STORAGE");
            //////Download File
            askpermission();
            //SaveImage(ImageViewer.this,extracteurl);
           // DownloadImage(extracteurl);
            BitmapDrawable bitmapDrawable = ((BitmapDrawable) imageView.getDrawable());// **This image view is loaded with image using picasso in oncreate**
            Bitmap bitmap = bitmapDrawable.getBitmap();
            String bitmapPath = MediaStore.Images.Media.insertimage(getContentResolver(),bitmap,"WallpaperApp_by_AshishApps"+String.valueOf(System.currentTimeMillis()),null);
           Toast.makeText(ImageViewer.this,"Image Downloaded",Toast.LENGTH_SHORT).show();
            // Uri bitmapUri = Uri.parse(bitmapPath);
        }
    });

许可方法的实现

 public void askpermission( ) {
   // String permisson="Manifest.permission."+permissiontype1;
    if (Build.VERSION.SDK_INT >= 23) {
        if (checkPermission()) {
            // Code for above or equal 23 API Oriented Device
            // Your Permission granted already .Do next code
        } else {
            requestPermission(); // Code for permission
        }
    } else {
        // Code for Below 23 API Oriented Devic// Do next code
    }

}

private boolean checkPermission( ) {                           //     Manifest.permission.READ_EXTERNAL_STORAGE
    int result = ContextCompat.checkSelfPermission(ImageViewer.this,Manifest.permission.READ_EXTERNAL_STORAGE);
    if (result == PackageManager.PERMISSION_GRANTED) {
        return true;
    } else {
        return false;
    }
}

private void requestPermission( ) {

    if (ActivityCompat.shouldShowRequestPermissionRationale(ImageViewer.this,Manifest.permission.READ_EXTERNAL_STORAGE)) {
        Toast.makeText(ImageViewer.this,"Write External Storage permission allows us to do store images. Please allow this permission in App Settings.",Toast.LENGTH_LONG).show();
    } else {
        ActivityCompat.requestPermissions(ImageViewer.this,new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},PERMISSION_REQUEST_CODE);
    }
}

@Override
public void onRequestPermissionsResult(int requestCode,String permissions[],int[] grantResults) {
    switch (requestCode) {
        case PERMISSION_REQUEST_CODE:
            if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                Log.e("value","Permission Granted,Now you can use local drive .");
            } else {
                Log.e("value","Permission Denied,You cannot use local drive .");
            }
            break;
    }
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)