Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ protected void onCreate(Bundle savedInstanceState) {

// Initialize ScreenCaptureManager for the Shaky library
((ShakyApplication) getApplication()).getShaky().initializeScreenCapture(this);

ViewCompat.setOnApplyWindowInsetsListener(
getWindow().findViewById(R.id.demo_background),
(v, insets) -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
import android.view.Display;
import android.view.WindowManager;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.activity.result.ActivityResult;
import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.contract.ActivityResultContracts;
import androidx.fragment.app.FragmentActivity;

import androidx.activity.result.ActivityResult;
import androidx.activity.result.ActivityResultLauncher;
Expand Down Expand Up @@ -81,6 +83,10 @@ public void requestCapturePermission(Activity activity, CaptureCallback callback
throw new IllegalStateException("ScreenCaptureManager must be initialized before requesting permission. Call initialize() in onCreate().");
}

if (mediaProjectionLauncher == null) {
throw new IllegalStateException("ScreenCaptureManager must be initialized before requesting permission. Call initialize() in onCreate().");
}

this.captureCallback = callback;

// Get screen metrics
Expand All @@ -105,10 +111,6 @@ public void requestCapturePermission(Activity activity, CaptureCallback callback
*/
private void handleActivityResult(ActivityResult result) {
if (result.getResultCode() == Activity.RESULT_OK && result.getData() != null) {
return false;
}

if (resultCode == Activity.RESULT_OK && data != null) {
// Start the foreground service before creating MediaProjection
ScreenCaptureService.start(appContext);

Expand Down
Loading