I am running an App that targets Android 13 on a Samsung device with Android 13.
I need to check at runtime if the notifications permission is granted or not and if it is not granted I need to request it,
here is how to request the new permission
pushNotificationPermissionLauncher.launch(android.Manifest.permission.POST_NOTIFICATIONS)
private val pushNotificationPermissionLauncher = registerForActivityResult(
ActivityResultContracts.RequestPermission()
) { granted ->
}
My Mainfest have the required permission delaration
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
But when i request the permisison i am getting this crash,
Failed looking up ApplicationInfo for com.testapp
android.content.pm.PackageManager$NameNotFoundException: com.testapp at android.app.ApplicationPackageManager.getApplicationInfoAsUser(ApplicationPackageManager.java:504)
at android.app.ApplicationPackageManager.getApplicationInfo(ApplicationPackageManager.java:487)
at android.app.ApplicationPackageManager.getApplicationInfo(ApplicationPackageManager.java:481)
at com.android.systemui.statusbar.notification.collection.TargetSdkResolver.resolveNotificationSdk(TargetSdkResolver.kt:46)
at com.android.systemui.statusbar.notification.collection.TargetSdkResolver.access$resolveNotificationSdk(TargetSdkResolver.kt:29)
at com.android.systemui.statusbar.notification.collection.TargetSdkResolver$initialize$1.onEntryBind(TargetSdkResolver.kt:36)
at com.android.systemui.statusbar.notification.collection.notifcollection.BindEntryEvent.dispatchToListener(NotifEvent.kt:48)
at com.android.systemui.statusbar.notification.collection.notifcollection.NotifEvent.dispatchTo(NotifEvent.kt:36)
at com.android.systemui.statusbar.notification.collection.NotifCollection.dispatchEventsAndRebuildList(NotifCollection.java:593)
at com.android.systemui.statusbar.notification.collection.NotifCollection.onNotificationPosted(NotifCollection.java:398)
at com.android.systemui.statusbar.notification.collection.NotifCollection.-$$Nest$monNotificationPosted(Unknown Source:0)
at com.android.systemui.statusbar.notification.collection.NotifCollection$1.onNotificationPosted(NotifCollection.java:838)
at com.android.systemui.statusbar.notification.collection.coalescer.GroupCoalescer$1.onNotificationPosted(GroupCoalescer.java:131)
at com.android.systemui.statusbar.NotificationListener.lambda$onNotificationPosted$1(NotificationListener.java:145)
at com.android.systemui.statusbar.NotificationListener.$r8$lambda$fICxp1QDMnCbsW19erR3r8vu9YQ(Unknown Source:0)
at com.android.systemui.statusbar.NotificationListener$$ExternalSyntheticLambda2.run(Unknown Source:6)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7898)
at java.lang.reflect.Method.invoke(Native Method)
at
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
any help, please?
Related
facebookincubator/Battery-Metrics repo's getSnapshot method in class SystemMetricsCollector is crashing because of java.lang.SecurityException: Calling identity is not authorized on android 13. It was working on android 12 and on versions before. Logs for the crash are:
java.lang.RuntimeException: Unable to start activity ComponentInfo{AppName/com.AppName.ux.activity.MainActivity}: java.lang.SecurityException: Calling identity is not authorized at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3686) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3823) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:101) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2306) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loopOnce(Looper.java:201) at android.os.Looper.loop(Looper.java:288) at android.app.ActivityThread.main(ActivityThread.java:7892) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936) Caused by: java.lang.SecurityException: Calling identity is not authorized at android.os.Parcel.createExceptionOrNull(Parcel.java:3011) at android.os.Parcel.createException(Parcel.java:2995) at android.os.Parcel.readException(Parcel.java:2978) at android.os.Parcel.readException(Parcel.java:2920) at android.net.INetworkStatsService$Stub$Proxy.openSessionForUsageStats(INetworkStatsService.java:469) at android.app.usage.NetworkStats.<init>(NetworkStats.java:111) at android.app.usage.NetworkStatsManager.querySummary(NetworkStatsManager.java:424) at android.app.usage.NetworkStatsManager.querySummary(NetworkStatsManager.java:397) at com.facebook.battery.metrics.network.NetworkStatsManagerBytesCollector.getBytesForType(NetworkStatsManagerBytesCollector.java:51) at com.facebook.battery.metrics.network.NetworkStatsManagerBytesCollector.getTotalBytes(NetworkStatsManagerBytesCollector.java:38) at com.facebook.battery.metrics.network.NetworkMetricsCollector.getSnapshot(NetworkMetricsCollector.java:53) at com.facebook.battery.metrics.network.NetworkMetricsCollector.getSnapshot(NetworkMetricsCollector.java:33) at com.facebook.battery.metrics.composite.CompositeMetricsCollector.getSnapshot(CompositeMetricsCollector.java:99) at com.AppName.features.appsetup.ux.workflow.tasks.LaunchScreenTask.process(LaunchScreenTask.java:66) at com.AppName.features.appsetup.ux.workflow.WorkflowExecutor.execute(WorkflowExecutor.java:84) at com.AppName.ux.activity.MainActivity.startWorkflow(MainActivity.java:414) at com.AppName.ux.activity.MainActivity.workflowDelegation(MainActivity.java:1134) at com.AppName.ux.activity.MainActivity.ecsEventHandler(MainActivity.java:568) at com.AppName.ux.activity.MainActivity.onCreate(MainActivity.java:324) at android.app.Activity.performCreate(Activity.java:8285) at android.app.Activity.performCreate(Activity.java:8264) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1384) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3667)
Any one have a suggestion how to solve this error ?
I am trying to run lock task with intent getLaunchIntentForPackage but I have no idea why this error is coming and which type of permission it wants to run this task.
java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 pkg=com.example.videoplayer cmp=com.example.videoplayer/.MainActivity } from ProcessRecord{fd194a9 7523:com.example.lock/u0a190} (pid=7523, uid=10190) with lockTaskMode=true
at android.os.Parcel.createExceptionOrNull(Parcel.java:2425)
at android.os.Parcel.createException(Parcel.java:2409)
at android.os.Parcel.readException(Parcel.java:2392)
at android.os.Parcel.readException(Parcel.java:2334)
at android.app.IActivityTaskManager$Stub$Proxy.startActivity(IActivityTaskManager.java:2326)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1758)
at android.app.Activity.startActivityForResult(Activity.java:5407)
at androidx.activity.ComponentActivity.startActivityForResult(ComponentActivity.java:597)
at android.app.Activity.startActivity(Activity.java:5747)
at com.example.lock.MainActivity.launchApp(MainActivity.kt:110)
at com.example.lock.MainActivity.onCreate$lambda-0(MainActivity.kt:62)
at com.example.lock.MainActivity.$r8$lambda$yGvyKllS4GN5cYzDCcbSf8EdXb0(Unknown Source:0)
at com.example.lock.MainActivity$$ExternalSyntheticLambda0.onClick(Unknown Source:2)
at android.view.View.performClick(View.java:7455)
at com.google.android.material.button.MaterialButton.performClick(MaterialButton.java:1194)
at android.view.View.performClickInternal(View.java:7432)
at android.view.View.access$3700(View.java:835)
at android.view.View$PerformClick.run(View.java:28810)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7842)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
Caused by: android.os.RemoteException: Remote stack trace:
at com.android.server.wm.SafeActivityOptions.checkPermissions(SafeActivityOptions.java:283)
at com.android.server.wm.SafeActivityOptions.getOptions(SafeActivityOptions.java:155)
at com.android.server.wm.ActivityStarter.executeRequest(ActivityStarter.java:1006)
at com.android.server.wm.ActivityStarter.execute(ActivityStarter.java:670)
at com.android.server.wm.ActivityTaskManagerService.startActivityAsUser(ActivityTaskManagerService.java:1223)
I'm currently running into the same error. The only thing I can hand to you is that it can be solved by using the DevicePolicyManager.setLockTaskPackages as stated on the android site: https://developer.android.com/work/dpc/dedicated-devices/lock-task-mode#allowlist_apps
I'm using Foreground Services for notification and it's working on other mobile phones as well it's working on an emulator also but in MI phone it's not working it shows error like this.
2020-07-01 17:47:25.783 4338-4338/com.example.notification_app E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.notification_app, PID: 4338
java.lang.RuntimeException: Unable to create service com.example.notification_app.my_service: java.lang.SecurityException: Permission Denial: startForeground from pid=4338, uid=10175 requires android.permission.FOREGROUND_SERVICE
at android.app.ActivityThread.handleCreateService(ActivityThread.java:3577)
at android.app.ActivityThread.access$1400(ActivityThread.java:200)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1689)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:201)
at android.app.ActivityThread.main(ActivityThread.java:6810)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)
Caused by: java.lang.SecurityException: Permission Denial: startForeground from pid=4338, uid=10175 requires android.permission.FOREGROUND_SERVICE
at android.os.Parcel.createException(Parcel.java:1953)
at android.os.Parcel.readException(Parcel.java:1921)
at android.os.Parcel.readException(Parcel.java:1871)
at android.app.IActivityManager$Stub$Proxy.setServiceForeground(IActivityManager.java:5104)
at android.app.Service.startForeground(Service.java:695)
at com.example.notification_app.my_service.startMyOwnForeground(my_service.java:57)
at com.example.notification_app.my_service.onCreate(my_service.java:44)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:3565)
at android.app.ActivityThread.access$1400(ActivityThread.java:200)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1689)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:201)
at android.app.ActivityThread.main(ActivityThread.java:6810)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)
2020-07-01 17:47:25.826 4338-4338/? I/Process: Sending signal. PID: 4338 SIG: 9
and in line number 48, I called a function startForeground(1, new Notification());
If you read carefully in the end of second line
requires android.permission.FOREGROUND_SERVICE
I was also facing the same error in one of my project I resolve it by adding permission in the manifest file. So just simply add foreground permission in the manifest file.
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"></uses-permission>
Hope it's work for you.
When requesting permission for fingerprint sensor manually for oreo dialog box does not show up.
I have listed the USE_FINGERPRINT permission in Manifest but still, I get an exception as
W/System.err: java.lang.SecurityException: Must have android.permission.USE_FINGERPRINT permission.: Neither user 10190 nor current process has android.permission.USE_FINGERPRINT.
at android.os.Parcel.readException(Parcel.java:2004)
at android.os.Parcel.readException(Parcel.java:1950)
at android.hardware.fingerprint.IFingerprintService$Stub$Proxy.isHardwareDetected(IFingerprintService.java:465)
at android.hardware.fingerprint.FingerprintManager.isHardwareDetected(FingerprintManager.java:835)
at ""ui.biometricAuth.BiometricAuth.getFingerPrintAuthError(BiometricAuth.java:174)
at ""ui.biometricAuth.BiometricAuth.isTouchIDEnabled(BiometricAuth.java:225)
at ""ui.usermanagement.LoginActivity.onCreate(LoginActivity.java:403)
at android.app.Activity.performCreate(Activity.java:7036)
at android.app.Activity.performCreate(Activity.java:7027)
W/System.err: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1231)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2864)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2989)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1688)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6753)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:482)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
I added the permission as follows before
<uses-permission
android:name="android.permission.USE_FINGERPRINT"
android:requiredFeature="false" />
now after removing android:requiredFeature="false" and adding only
<uses-permission android:name="android.permission.USE_FINGERPRINT" />
worked fine for all the OS versions.
A clean build (or just rebuild) works too.
add android.permission.USE_BIOMETRIC
I've tried this code but It's not working Properly.
Intent intent = new Intent("android.location.GPS_ENABLED_CHANGE");
intent.putExtra("enabled", true);
sendBroadcast(intent, Manifest.permission.WRITE_SECURE_SETTINGS);
Getting this Error:
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.setting/com.setting.activity.TraceLocationActivity}:
java.lang.SecurityException: Permission Denial: not allowed to send
broadcast android.location.GPS_ENABLED_CHANGE from pid=28258,
uid=10395
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2793)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2864)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1567)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:156)
at android.app.ActivityThread.main(ActivityThread.java:6523)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:942)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832)
Caused by: java.lang.SecurityException: Permission Denial: not allowed to send
broadcast android.location.GPS_ENABLED_CHANGE from pid=28258,
uid=10395
at android.os.Parcel.readException(Parcel.java:1665)
at android.os.Parcel.readException(Parcel.java:1618)
at android.app.ActivityManagerProxy.broadcastIntent(ActivityManagerNative.java:3533)
at android.app.ContextImpl.sendBroadcast(ContextImpl.java:1012)
at android.content.ContextWrapper.sendBroadcast(ContextWrapper.java:426)
at com.setting.activity.TraceLocationActivity.onCreate(TraceLocationActivity.java:46)
at android.app.Activity.performCreate(Activity.java:6915)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2746)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2864)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1567)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:156)
at android.app.ActivityThread.main(ActivityThread.java:6523)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:942)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832)
How can i On GPS Automatically without asking User?
This is not possible, for obvious privacy and security reasons.