diff --git a/hbrecorder/src/main/java/com/hbisoft/hbrecorder/HBRecorder.java b/hbrecorder/src/main/java/com/hbisoft/hbrecorder/HBRecorder.java index 0ee7eef..b3de14d 100644 --- a/hbrecorder/src/main/java/com/hbisoft/hbrecorder/HBRecorder.java +++ b/hbrecorder/src/main/java/com/hbisoft/hbrecorder/HBRecorder.java @@ -159,21 +159,6 @@ private void startService(Intent data) { observer = new FileObserver(String.valueOf(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES)), activity, HBRecorder.this); observer.startWatching(); - if (audioBitrate == 0){ - audioBitrate = 128000; - } - if (audioSamplingRate == 0){ - audioSamplingRate = 44100; - } - - if (notificationTitle.equals("")){ - notificationTitle = "Recording your screen"; - } - - if (notificationDescription.equals("")){ - notificationDescription = "Drag down to stop the recording"; - } - Intent service = new Intent(context, ScreenRecordService.class); service.putExtra("code", resultCode); service.putExtra("data", data); diff --git a/hbrecorder/src/main/java/com/hbisoft/hbrecorder/ScreenRecordService.java b/hbrecorder/src/main/java/com/hbisoft/hbrecorder/ScreenRecordService.java index 93b5456..a25e310 100755 --- a/hbrecorder/src/main/java/com/hbisoft/hbrecorder/ScreenRecordService.java +++ b/hbrecorder/src/main/java/com/hbisoft/hbrecorder/ScreenRecordService.java @@ -63,11 +63,39 @@ public int onStartCommand(Intent intent, int flags, int startId) { String notificationDescription = intent.getStringExtra("notificationDescription"); boolean shouldShowNotification = intent.getBooleanExtra("shouldShowNotification", true); String notificationButtonText = intent.getStringExtra("notificationButtonText"); + mResultCode = intent.getIntExtra("code", -1); + mResultData = intent.getParcelableExtra("data"); + mScreenWidth = intent.getIntExtra("width", 720); + mScreenHeight = intent.getIntExtra("height", 1280); + mScreenDensity = intent.getIntExtra("density", 1); + isVideoHD = intent.getBooleanExtra("quality", true); + isAudioEnabled = intent.getBooleanExtra("audio", true); + path = intent.getStringExtra("path"); + name = intent.getStringExtra("fileName"); + + filePath = name; + audioBitrate = intent.getIntExtra("audioBitrate", 128000); + audioSamplingRate = intent.getIntExtra("audioSamplingRate", 44100); if (notificationButtonText==null){ notificationButtonText = "STOP RECORDING"; } + if (audioBitrate == 0){ + audioBitrate = 128000; + } + if (audioSamplingRate == 0){ + audioSamplingRate = 44100; + } + + if (notificationTitle == null || notificationTitle.equals("")){ + notificationTitle = "Recording your screen"; + } + + if (notificationDescription == null || notificationDescription.equals("")){ + notificationDescription = "Drag down to stop the recording"; + } + //Check if notification should be shown if (shouldShowNotification) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { @@ -110,19 +138,6 @@ public int onStartCommand(Intent intent, int flags, int startId) { * Notification End */ - mResultCode = intent.getIntExtra("code", -1); - mResultData = intent.getParcelableExtra("data"); - mScreenWidth = intent.getIntExtra("width", 720); - mScreenHeight = intent.getIntExtra("height", 1280); - mScreenDensity = intent.getIntExtra("density", 1); - isVideoHD = intent.getBooleanExtra("quality", true); - isAudioEnabled = intent.getBooleanExtra("audio", true); - path = intent.getStringExtra("path"); - name = intent.getStringExtra("fileName"); - - filePath = name; - audioBitrate = intent.getIntExtra("audioBitrate", 128000); - audioSamplingRate = intent.getIntExtra("audioSamplingRate", 44100); if (path == null) { path = String.valueOf(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES));