代码之家  ›  专栏  ›  技术社区  ›  EugeneS

创建视频并单击按钮时出错。Logcat E/WindowManager:android.view.WindowLeaked:活动

  •  0
  • EugeneS  · 技术社区  · 6 年前

    我有API版本26,我的系统一切正常,上面的用户在点击save按钮时会出错。

    这个项目最初是用Java1.7编写的

    可以采取哪些步骤来纠正错误?

    这个错误是什么,为什么会发生?

    我有API版本26,我的系统一切正常,上面的用户在点击save按钮时会出错。

    我的比尔德·格雷德

    buildscript {
    repositories {
        jcenter()
        google()
    }
       dependencies {
        classpath 'com.android.tools.build:gradle:3.4.2'
    }
    }
    apply plugin: 'com.android.application'
    
    repositories {
    jcenter()
    }
    
    android {
    compileSdkVersion 28
        buildToolsVersion '28.0.3'
    
    defaultConfig {
        applicationId "com.."
        minSdkVersion 14
        targetSdkVersion 28
        versionCode 2
        versionName "1.24"
        vectorDrawables.useSupportLibrary true
    }
    
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    if (RunForEmulator) {
        splits {
            abi {
                enable true
                reset()
                include 'x86', 'arm64-v8a', 'armeabi-v7a', 'x86_64'
                universalApk true
            }
        }
    }
    }
    
    dependencies {
    
    
    
    
    
    
    
    
    
    
    testImplementation 'junit:junit:4.12'
    
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation project(':library')
    testImplementation 'com.android.support.test:runner:1.0.2'
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.android.support:recyclerview-v7:28.0.0'
    implementation 'de.hdodenhof:circleimageview:2.2.0'
    implementation 'me.iwf.photopicker:PhotoPicker:0.9.12@aar'
    implementation 'com.github.bumptech.glide:glide:4.3.1'
    implementation 'com.android.support:design:28.0.0'
    }
    

    java文件

    public void saveVideo() {
        mPhotoMoviePlayer.pause();
        final ProgressDialog dialog = new 
    ProgressDialog(mDemoView.getActivity());
        dialog.setMessage("saving video...");
        dialog.setMax(100);
        dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        dialog.setCancelable(false);
        dialog.show();
        final long startRecodTime = System.currentTimeMillis();
        final GLMovieRecorder recorder = new 
    GLMovieRecorder(mDemoView.getActivity());
        final File file = initVideoFile();
        GLTextureView glTextureView = mDemoView.getGLView();
        int bitrate = glTextureView.getWidth() * glTextureView.getHeight() > 
    1000 * 1500 ? 8000000 : 4000000;
        recorder.configOutput(glTextureView.getWidth(), 
    glTextureView.getHeight(), bitrate, 30, 1, file.getAbsolutePath());
    
        PhotoMovie newPhotoMovie = 
       PhotoMovieFactory.generatePhotoMovie(mPhotoMovie.getPhotoSource(), 
    mMovieType);
        GLSurfaceMovieRenderer newMovieRenderer = new 
    GLSurfaceMovieRenderer(mMovieRenderer);
        newMovieRenderer.setPhotoMovie(newPhotoMovie);
        String audioPath = null;
        if(mMusicUri!=null) {
            audioPath = UriUtil.getPath(mDemoView.getActivity(), mMusicUri);
        }
        if (!TextUtils.isEmpty(audioPath)) {
            if (Build.VERSION.SDK_INT < 18) {
    
    Toast.makeText(mDemoView.getActivity().getApplicationContext(), "Mix audio 
    needs api18!", Toast.LENGTH_LONG).show();
            } else {
                recorder.setMusic(audioPath);
            }
        }
        recorder.setDataSource(newMovieRenderer);
        recorder.startRecord(new GLMovieRecorder.OnRecordListener() {
            @Override
            public void onRecordFinish(boolean success) {
                File outputFile = file;
                long recordEndTime = System.currentTimeMillis();
                MLog.i("Record", "record:" + (recordEndTime - 
    startRecodTime));
                dialog.dismiss();
                if (success) {
    
    Toast.makeText(mDemoView.getActivity().getApplicationContext(), "Video save to path:" + outputFile.getAbsolutePath(), Toast.LENGTH_LONG).show();
    
                    mDemoView.getActivity().sendBroadcast(new 
    Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.fromFile(file)));
    
    
                    Intent intent = new Intent();
                    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    intent.setAction(Intent.ACTION_VIEW);
                    String type = "video/*";
                    intent.setDataAndType(Uri.fromFile(outputFile), type);
                    mDemoView.getActivity().startActivity(intent);
                } else {
    
    Toast.makeText(mDemoView.getActivity().getApplicationContext(), "record error!", Toast.LENGTH_LONG).show();
                }
                if(recorder.getAudioRecordException()!=null){
    
    Toast.makeText(mDemoView.getActivity().getApplicationContext(), "record audio failed:"+recorder.getAudioRecordException().toString(), 
    Toast.LENGTH_LONG).show();
                }
            }
    
            @Override
            public void onRecordProgress(int recordedDuration, int totalDuration) {
                dialog.setProgress((int) (recordedDuration / (float) totalDuration * 100));
            }
        });
    }
    
    0 回复  |  直到 6 年前