Reputation: 23
I am trying to make my camera app launchable from the lock screen. I made a shortcut of the camera app in the lock screen but when I am trying to access the camera by sliding its icon in the lock screen it requirres to unlock the phone first. It there any way to give the app the privilege to run over the lock screen.
Ps: When I launch the App from android studio it works well.
Here is the keyguardManger unlock request :
activity.window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON or
WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON)
activity.setShowWhenLocked(true)
activity.setTurnScreenOn(true)
val keyguardManager = activity.getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager
keyguardManager.requestDismissKeyguard(activity, object : KeyguardDismissCallback() {
override fun onDismissSucceeded() {
// Keyguard was successfully dismissed
}
override fun onDismissCancelled() {
// Dismissal was cancelled
}
override fun onDismissError() {
// An error occurred while trying to dismiss the keyguard
}
})
and the manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
>
<uses-feature
android:name="android.hardware.camera2"
android:required="false" />
<uses-feature android:name="android.hardware.camera.any" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO"/>
<uses-permission android:name="android.permission.READ_MEDIA_VISUAL_USER_SELECTED" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_CAMERA" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MICROPHONE" />
<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<application
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme" >
<!--implementation of a file provider in order to be able to share the video to other platforms-->
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="com.nerovero.camerago.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
<!--check whether enabled attribute is necessary in the service or not -->
<service
android:name=".VideoRecordingService"
android:foregroundServiceType="camera|microphone"
android:enabled="true"
android:exported="false"
/>
<activity
android:name=".SettingsActivity"
android:enabled="true"
android:exported="false"
android:showWhenLocked="true"
android:turnScreenOn="true"
android:showOnLockScreen="true"
/>
<activity
android:name=".PreviewActivity"
android:exported="true"
>
</activity>
<!--android:showWhenLocked="true" & android:turnScreenOn="true" and the others below are subject to removal from the manifest if the
the lock bypassing is not working-->
<activity
android:name=".CameraActivity"
android:exported="true"
android:showWhenLocked="true"
android:turnScreenOn="true"
android:showOnLockScreen="true"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME"/>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
I tried different kind of permissions such as "android.permission.DISABLE_KEYGUARD" but nothing works.
Upvotes: 0
Views: 65