我有一个可以选择上传图像的代码,但是我想把它改成pdf,当我把mediastore.images改成mediastore.files时,我怎么能把它打上点呢?这里是我的代码
public void sec(View view){
if(ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE)!= PackageManager.PERMISSION_GRANTED){
if(ActivityCompat.shouldShowRequestPermissionRationale(this,Manifest.permission.READ_EXTERNAL_STORAGE)){
Snackbar.make(view,"Dosyalara Erişim İçin İzin Gerekiyor",Snackbar.LENGTH_INDEFINITE).setAction("İzin ver", new View.OnClickListener() {
@Override
public void onClick(View v) {
permissonLauncher.launch(Manifest.permission.READ_EXTERNAL_STORAGE);
}
}).show();
}else{
permissonLauncher.launch(Manifest.permission.READ_EXTERNAL_STORAGE);
}
}else{
Intent intettoFiles=new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
activityResultLauncher.launch(intettoFiles);
}
}
public void registerLauncher(){
activityResultLauncher=registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), new ActivityResultCallback<ActivityResult>() {
@Override
public void onActivityResult(ActivityResult result) {
if(result.getResultCode()==RESULT_OK){
Intent intentfromresult=result.getData();
if(intentfromresult!=null){
CVDATA=intentfromresult.getData();
binding.imageView.setImageURI(CVDATA);
}
}
}
});
permissonLauncher=registerForActivityResult(new ActivityResultContracts.RequestPermission(), new ActivityResultCallback<Boolean>() {
@Override
public void onActivityResult(Boolean result) {
if (result) {
Intent intenttoFiles=new Intent(Intent.ACTION_PICK,MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
activityResultLauncher.launch(intenttoFiles);
} else{
Toast.makeText(Profil.this, "İzin Gerekiyor!", Toast.LENGTH_SHORT).show();
}
}
});
}
暂无答案!
目前还没有任何答案,快来回答吧!