申请camera与record audio权限

申请camera与record audio权限
pull/107/head
xufulong 5 years ago
parent 409cadf625
commit 52d302d59f
  1. 11
      app/src/main/java/com/frank/ffmpeg/activity/BaseActivity.java
  2. 7
      app/src/main/java/com/frank/ffmpeg/activity/LiveActivity.java

@ -2,6 +2,7 @@ package com.frank.ffmpeg.activity;
import android.Manifest;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import androidx.annotation.Nullable;
@ -28,13 +29,19 @@ public abstract class BaseActivity extends AppCompatActivity implements View.OnC
private final static int REQUEST_CODE = 1234;
private final static String[] permissions = new String[] {
Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.READ_EXTERNAL_STORAGE};
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.CAMERA,
Manifest.permission.RECORD_AUDIO};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestPermission();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
&& checkSelfPermission(permissions[0]) != PackageManager.PERMISSION_GRANTED
&& checkSelfPermission(permissions[1]) != PackageManager.PERMISSION_GRANTED ) {
requestPermission();
}
setContentView(getLayoutId());
}

@ -1,6 +1,5 @@
package com.frank.ffmpeg.activity;
import android.Manifest;
import android.annotation.SuppressLint;
import android.hardware.Camera;
import android.media.AudioFormat;
@ -29,7 +28,6 @@ import com.frank.live.param.VideoParam;
public class LiveActivity extends BaseActivity implements CompoundButton.OnCheckedChangeListener, LiveStateChangeListener {
private final static String TAG = LiveActivity.class.getSimpleName();
private final static String[] permissions = new String[]{Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO};
private final static String LIVE_URL = "rtmp://192.168.1.102/live/stream";
private final static int MSG_ERROR = 100;
private SurfaceHolder surfaceHolder;
@ -59,7 +57,6 @@ public class LiveActivity extends BaseActivity implements CompoundButton.OnCheck
hideActionBar();
initView();
requestPermission(permissions);
initPusher();
}
@ -114,7 +111,9 @@ public class LiveActivity extends BaseActivity implements CompoundButton.OnCheck
@Override
protected void onDestroy() {
super.onDestroy();
livePusher.release();
if (livePusher != null) {
livePusher.release();
}
}
@Override

Loading…
Cancel
Save