Code Monkey home page Code Monkey logo

Comments (8)

abdullah432 avatar abdullah432 commented on June 23, 2024 3

After adding this line, android:foregroundServiceType="mediaProjection" now it's working.
Add it here: <service android:name="changjoopark.com.flutter_foreground_plugin.FlutterForegroundService" android:foregroundServiceType="mediaProjection"/>
AndroidManefist.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
	xmlns:tools="http://schemas.android.com/tools"
	package="com.kukustudio.textcrawler">
	<uses-permission android:name="android.permission.WAKE_LOCK" />
	<uses-sdk
		android:minSdkVersion="23"
		tools:overrideLibrary="changjoopark.com.flutter_foreground_plugin" />
	<application
        android:label="Star Crawler"
        android:icon="@mipmap/launcher_icon">
		<activity android:name=".MainActivity" android:launchMode="singleTop" android:theme="@style/LaunchTheme" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" android:hardwareAccelerated="true" android:windowSoftInputMode="adjustResize">
			<!--
			Specifies an Android theme to apply to this Activity as soon as
			the Android process has started. This theme is visible to the user
			while the Flutter UI initializes. After that, this theme continues
			to determine the Window background behind the Flutter UI.
			-->
			<meta-data android:name="io.flutter.embedding.android.NormalTheme" android:resource="@style/NormalTheme" />
			<!--
			Displays an Android View that continues showing the launch screen
			Drawable until Flutter paints its first frame, then this splash
			screen fades out. A splash screen is useful to avoid any visual
			gap between the end of Android's launch screen and the painting of
			Flutter's first frame.
			-->
			<meta-data android:name="io.flutter.embedding.android.SplashScreenDrawable" android:resource="@drawable/launch_background" />
			<intent-filter>
				<action android:name="android.intent.action.MAIN" />
				<category android:name="android.intent.category.LAUNCHER" />
			</intent-filter>
		</activity>
        <service android:name="changjoopark.com.flutter_foreground_plugin.FlutterForegroundService" android:foregroundServiceType="mediaProjection"/>
		<!--
		Don't delete the meta-data below.
		This is used by the Flutter tool to generate GeneratedPluginRegistrant.java
		-->
		<meta-data android:name="flutterEmbedding" android:value="2" />
	</application>
</manifest>

from flutter_screen_recording.

salime45 avatar salime45 commented on June 23, 2024

This plugin use https://pub.dev/packages/flutter_foreground_plugin for that. You have to follow the instruccions and add the configuration to your AndroidManifest

from flutter_screen_recording.

abdullah432 avatar abdullah432 commented on June 23, 2024

Thanks for replying. I know that and i add the configuration to my AndroidManifest but still app crash when click on start record button in compileSdkVersion 29 and targetSdkVersion 29. I checked your example too which is running compileSdkVersion 28 and targetSdkVersion 28, please change it to 29 and see by yourself.

from flutter_screen_recording.

abdullah432 avatar abdullah432 commented on June 23, 2024

Please reopen the issue until it is fixed.

from flutter_screen_recording.

abdullah432 avatar abdullah432 commented on June 23, 2024

You made a great plugin but documentation should include these settings. It's so frustrating. It takes me more than 3 days to finally make it work. Thanks for the plugin.

from flutter_screen_recording.

ifananomali avatar ifananomali commented on June 23, 2024

After adding this line, android:foregroundServiceType="mediaProjection" now it's working.
Add it here: <service android:name="changjoopark.com.flutter_foreground_plugin.FlutterForegroundService" android:foregroundServiceType="mediaProjection"/>
AndroidManefist.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
	xmlns:tools="http://schemas.android.com/tools"
	package="com.kukustudio.textcrawler">
	<uses-permission android:name="android.permission.WAKE_LOCK" />
	<uses-sdk
		android:minSdkVersion="23"
		tools:overrideLibrary="changjoopark.com.flutter_foreground_plugin" />
	<application
        android:label="Star Crawler"
        android:icon="@mipmap/launcher_icon">
		<activity android:name=".MainActivity" android:launchMode="singleTop" android:theme="@style/LaunchTheme" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" android:hardwareAccelerated="true" android:windowSoftInputMode="adjustResize">
			<!--
			Specifies an Android theme to apply to this Activity as soon as
			the Android process has started. This theme is visible to the user
			while the Flutter UI initializes. After that, this theme continues
			to determine the Window background behind the Flutter UI.
			-->
			<meta-data android:name="io.flutter.embedding.android.NormalTheme" android:resource="@style/NormalTheme" />
			<!--
			Displays an Android View that continues showing the launch screen
			Drawable until Flutter paints its first frame, then this splash
			screen fades out. A splash screen is useful to avoid any visual
			gap between the end of Android's launch screen and the painting of
			Flutter's first frame.
			-->
			<meta-data android:name="io.flutter.embedding.android.SplashScreenDrawable" android:resource="@drawable/launch_background" />
			<intent-filter>
				<action android:name="android.intent.action.MAIN" />
				<category android:name="android.intent.category.LAUNCHER" />
			</intent-filter>
		</activity>
        <service android:name="changjoopark.com.flutter_foreground_plugin.FlutterForegroundService" android:foregroundServiceType="mediaProjection"/>
		<!--
		Don't delete the meta-data below.
		This is used by the Flutter tool to generate GeneratedPluginRegistrant.java
		-->
		<meta-data android:name="flutterEmbedding" android:value="2" />
	</application>
</manifest>

Thank you for helping, I got this problem too

from flutter_screen_recording.

deepak-ariceum avatar deepak-ariceum commented on June 23, 2024

Is it working for everyone?
I have done the exact same things, but it's not working for me. Please let me know.
Gives me the below error,

 java.lang.SecurityException: Media projections require a foreground service of type ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION
E/AndroidRuntime( 5654):        at android.app.ActivityThread.deliverResults(ActivityThread.java:5097)
E/AndroidRuntime( 5654):        at android.app.ActivityThread.handleSendResult(ActivityThread.java:5138)
E/AndroidRuntime( 5654):        at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:51)
E/AndroidRuntime( 5654):        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
E/AndroidRuntime( 5654):        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
E/AndroidRuntime( 5654):        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2147)
E/AndroidRuntime( 5654):        at android.os.Handler.dispatchMessage(Handler.java:107)
E/AndroidRuntime( 5654):        at android.os.Looper.loop(Looper.java:237)
E/AndroidRuntime( 5654):        at android.app.ActivityThread.main(ActivityThread.java:7807)
E/AndroidRuntime( 5654):        at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime( 5654):        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
E/AndroidRuntime( 5654):        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1047)
E/AndroidRuntime( 5654): Caused by: java.lang.SecurityException: Media projections require a foreground service of type ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION
E/AndroidRuntime( 5654):        at android.os.Parcel.createException(Parcel.java:2088)
E/AndroidRuntime( 5654):        at android.os.Parcel.readException(Parcel.java:2056)
E/AndroidRuntime( 5654):        at android.os.Parcel.readException(Parcel.java:2004)
E/AndroidRuntime( 5654):        at android.media.projection.IMediaProjection$Stub$Proxy.start(IMediaProjection.java:231)
E/AndroidRuntime( 5654):        at android.media.projection.MediaProjection.<init>(MediaProjection.java:68)
E/AndroidRuntime( 5654):        at android.media.projection.MediaProjectionManager.getMediaProjection(MediaProjectionManager.java:147)
E/AndroidRuntime( 5654):        at com.isvisoft.flutter_screen_recording.FlutterScreenRecordingPlugin.onActivityResult(FlutterScreenRecordingPlugin.kt:63)
E/AndroidRuntime( 5654):        at io.flutter.embedding.engine.FlutterEngineConnectionRegistry$FlutterEngineActivityPluginBinding.onActivityResult(FlutterEngineConnectionRegistry.java:805)
E/AndroidRuntime( 5654):        at io.flutter.embedding.engine.FlutterEngineConnectionRegistry.onActivityResult(FlutterEngineConnectionRegistry.java:428)
E/AndroidRuntime( 5654):        at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onActivityResult(FlutterActivityAndFragmentDelegate.java:802)
E/AndroidRuntime( 5654):        at io.flutter.embedding.android.FlutterActivity.onActivityResult(FlutterActivity.java:724)
E/AndroidRuntime( 5654):        at android.app.Activity.dispatchActivityResult(Activity.java:8292)
E/AndroidRuntime( 5654):        at android.app.ActivityThread.deliverResults(ActivityThread.java:5090)
E/AndroidRuntime( 5654):        ... 11 more
E/AndroidRuntime( 5654): Caused by: android.os.RemoteException: Remote stack trace:
E/AndroidRuntime( 5654):        at com.android.server.media.projection.MediaProjectionManagerService$MediaProjection.start(MediaProjectionManagerService.java:501)
E/AndroidRuntime( 5654):        at android.media.projection.IMediaProjection$Stub.onTransact(IMediaProjection.java:135)
E/AndroidRuntime( 5654):        at android.os.Binder.execTransactInternal(Binder.java:1021)
E/AndroidRuntime( 5654):        at android.os.Binder.execTransact(Binder.java:994)

from flutter_screen_recording.

adigujjar avatar adigujjar commented on June 23, 2024

@deepak-ariceum
use this one in latest version
<service android:name="com.foregroundservice.ForegroundService" android:foregroundServiceType="mediaProjection"> </service>

   instead of 
   
           <service android:name="changjoopark.com.flutter_foreground_plugin.FlutterForegroundService" android:foregroundServiceType="mediaProjection"/>

from flutter_screen_recording.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.