Skip to content

Commit

Permalink
Fix crash after selected video below Android 8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
cyunrei committed Aug 11, 2020
1 parent ec2110a commit 2dc8b33
Showing 1 changed file with 2 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,11 @@ public void onClick(View p1) {
});
}

@TargetApi(Build.VERSION_CODES.DONUT)
private void getPermission() {
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED)
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1);
}

@TargetApi(Build.VERSION_CODES.GINGERBREAD)
private void updateDialog() {
final AlertDialog.Builder normalDialog = new AlertDialog.Builder(MainActivity.this);
normalDialog.setTitle(getString(R.string.update_log) + "(" + getString(R.string.version_name) + ")");
Expand All @@ -119,18 +117,17 @@ private void chooseVideo() {
startActivityForResult(intent, 1);
}

@TargetApi(Build.VERSION_CODES.O)
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == Activity.RESULT_OK) {
Uri uri = data.getData();
assert uri != null;
if ("file".equalsIgnoreCase(uri.getScheme())) {
copyFile(new File(Objects.requireNonNull(uri.getPath())), new File(getFilesDir().toPath() + "/file.mp4"));
copyFile(new File(Objects.requireNonNull(uri.getPath())), new File(getFilesDir() + "/file.mp4"));
VideoLiveWallpaper.setToWallPaper(this);
return;
}
copyFile(new File(getPath(this, uri)), new File(getFilesDir().toPath() + "/file.mp4"));
copyFile(new File(getPath(this, uri)), new File(getFilesDir() + "/file.mp4"));
VideoLiveWallpaper.setToWallPaper(this);
}

Expand Down

0 comments on commit 2dc8b33

Please sign in to comment.