firebase dynamic link causes ActivityNotFoundException on targetSdk 33 - android

Has anyone faced this issue? When I build the app on targetSdk 33, app wont open dynamic link which crashes on ActivityNotFoundException on my pixel 6 android 13.
Build setup causing crash:
compileSdk = 33
targetSdk = 33
minSdk = 23
buildTools = "33.0.1"
logcat crash:
Activity not found to handle Intent action [CONTEXT service_id=77 ]
android.content.ActivityNotFoundException: Unable to find explicit activity class {com.somecompany.app/com.somecompany.app.MainActivity}; have you declared this activity in your AndroidManifest.xml, or does your intent not match its declared <intent-filter>?
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:2197)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1839)
at android.app.Activity.startActivityForResult(Activity.java:5471)
at hcl.platform_startActivityForResult(:com.google.android.gms#230313044#23.03.13 (190400-503260631):2)
at hck.startActivityForResult(:com.google.android.gms#230313044#23.03.13 (190400-503260631):2)
at com.google.android.chimera.android.Activity.startActivityForResult(:com.google.android.gms#230313044#23.03.13 (190400-503260631):2)
at hgw.startActivityForResult(:com.google.android.gms#230313044#23.03.13 (190400-503260631):2)
at hck.public_startActivityForResult(:com.google.android.gms#230313044#23.03.13 (190400-503260631):2)
at hcl.startActivityForResult(:com.google.android.gms#230313044#23.03.13 (190400-503260631):3)
at android.app.Activity.startActivityForResult(Activity.java:5429)
at hcl.platform_startActivityForResult(:com.google.android.gms#230313044#23.03.13 (190400-503260631):1)
at hck.startActivityForResult(:com.google.android.gms#230313044#23.03.13 (190400-503260631):1)
at com.google.android.chimera.android.Activity.startActivityForResult(:com.google.android.gms#230313044#23.03.13 (190400-503260631):1)
at hgw.startActivityForResult(:com.google.android.gms#230313044#23.03.13 (190400-503260631):1)
at hck.public_startActivityForResult(:com.google.android.gms#230313044#23.03.13 (190400-503260631):1)
at hcl.startActivityForResult(:com.google.android.gms#230313044#23.03.13 (190400-503260631):1)
at android.app.Activity.startActivity(Activity.java:5927)
at hcl.platform_startActivity(:com.google.android.gms#230313044#23.03.13 (190400-503260631):2)
at hck.startActivity(:com.google.android.gms#230313044#23.03.13 (190400-503260631):2)
at com.google.android.chimera.android.Activity.startActivity(:com.google.android.gms#230313044#23.03.13 (190400-503260631):2)
at hck.public_startActivity(:com.google.android.gms#230313044#23.03.13 (190400-503260631):2)
at hcl.startActivity(:com.google.android.gms#230313044#23.03.13 (190400-503260631):3)
at android.app.Activity.startActivity(Activity.java:5894)
at hcl.platform_startActivity(:com.google.android.gms#230313044#23.03.13 (190400-503260631):1)
at hck.startActivity(:com.google.android.gms#230313044#23.03.13 (190400-503260631):1)
at com.google.android.chimera.android.Activity.startActivity(:com.google.android.gms#230313044#23.03.13 (190400-503260631):1)
at kmq.x(:com.google.android.gms#230313044#23.03.13 (190400-503260631):4)
at kmr.onPostExecute(:com.google.android.gms#230313044#23.03.13 (190400-503260631):3)
at android.os.AsyncTask.finish(AsyncTask.java:771)
at android.os.AsyncTask.-$$Nest$mfinish(Unknown Source:0)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:788)
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:7872)
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)
workaroud build setup which works normally:
compileSdk = 33
targetSdk = 32
minSdk = 23
buildTools = "33.0.1"
Just in case i will add my intent filter:
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:host="mydomain.page.link"
android:pathPrefix="/link"
android:scheme="http"/>
<data android:host="mydomain.page.link"
android:pathPrefix="/link"
android:scheme="https"/>
</intent-filter>
Any suggestion fix for targetSdk 33?

add android:autoVerify="true" in intent filter menifest file
<intent-filter android:autoVerify="true">

Related

OneSignal Notification Click Crashes App - ActivityNotFoundException

I have an Ionic app that uses OneSignal to send notifications to users. I have updated my project to use Android 12 (API level 32), which also required an upgrade of Capacitor to version 4:
ext {
minSdkVersion = 22
compileSdkVersion = 32
targetSdkVersion = 32
androidxActivityVersion = '1.4.0'
androidxAppCompatVersion = '1.4.2'
androidxCoordinatorLayoutVersion = '1.2.0'
androidxCoreVersion = '1.8.0'
androidxFragmentVersion = '1.4.1'
junitVersion = '4.13.2'
androidxJunitVersion = '1.1.3'
androidxEspressoCoreVersion = '3.4.0'
cordovaAndroidVersion = '10.1.1'
coreSplashScreenVersion = '1.0.0-rc01'
androidxWebkitVersion = '1.4.0'
}
Since the update, the app crashes whenever a user clicks/taps on the notification. The error reported is as follows:
Stack trace:
capacitor.build.gradle:
Android.Manifest.xml
I have added the android:exported="true" activity attribute as specified by the Capacitor upgrade guide.
Please advise why the app might crash when clicking on notifications?
Looks like OneSignal updated its documentation. compileSdk & targetSdkVersion 33 seems to be required. docs
Validate your target SDK version is at least version 33.
I'm guessing this was the culprit, will update here later.
I was able to replicate the issue. With ADB connected, I got the following error with more details than the one in Play Store.
Turns out it was an intent filter issue for us. On android we don't have an intent filter for launch URLs with link://, however, we were sending notifications with launch URLs starting with link://.
Solution is adding an intent filter at AndroidManifest.xml, under . Note that with that filter in place, you can open your with the intent filter you provide.
<activity
android:exported="true"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode|layoutDirection"
android:name="com.hediyesepeti.app.MainActivity"
android:label="#string/title_activity_main"
android:theme="#style/AppTheme.NoActionBarLaunch"
android:launchMode="singleTask"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<!-- Intent Filters For Opening App via URLS -->
<!-- link://#URL -->
<intent-filter>
<data android:scheme="link"/>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
</intent-filter>
</activity>
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.hediyesepeti.app, PID: 19178
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.hediyesepeti.app/com.onesignal.NotificationOpenedReceiver}: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=link://www.hediyesepeti.com/... flg=0x10000000 }
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3676)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3813)
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:2308)
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: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)
Caused by: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=link://www.hediyesepeti.com/... flg=0x10000000 }
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:2161)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1805)
at android.app.Activity.startActivityForResult(Activity.java:5470)
at android.app.Activity.startActivityForResult(Activity.java:5428)
at android.app.Activity.startActivity(Activity.java:5926)
at android.app.Activity.startActivity(Activity.java:5893)
at com.onesignal.OneSignal.openDestinationActivity(OneSignal.java:2443)
at com.onesignal.OneSignal.handleNotificationOpen(OneSignal.java:2423)
at com.onesignal.NotificationOpenedProcessor.processIntent(NotificationOpenedProcessor.java:116)
at com.onesignal.NotificationOpenedProcessor.processFromContext(NotificationOpenedProcessor.java:64)
at com.onesignal.NotificationOpenedReceiverBase.onCreate(NotificationOpenedReceiverBase.kt:36)
at android.app.Activity.performCreate(Activity.java:8290)
at android.app.Activity.performCreate(Activity.java:8269)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1384)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3657)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3813)
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:2308)
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: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)

Android 11 Api 30 throws java.lang.SecurityException

i have a little problem with my android authenticator app ... this app is working on android 8.1 without any problem but since Android 11 it is throwing this exception :
java.lang.SecurityException: Permission Denial: package=android does not belong to uid=1010197
at com.android.server.wm.ActivityTaskManagerService.startActivityAsUser(ActivityTaskManagerService.java:1072)
at com.android.server.wm.ActivityTaskManagerService.assertPackageMatchesCallingUid(ActivityTaskManagerService.java:2598)
at com.android.server.wm.ActivityTaskManagerService.startActivityAsUser(ActivityTaskManagerService.java:1081)
at com.android.server.wm.ActivityTaskManagerService.startActivityAsUser(ActivityTaskManagerService.java:1072)
at android.app.ContextImpl.startActivityAsUser(ContextImpl.java:1032)
at android.app.ContextImpl.startActivityAsUser(ContextImpl.java:1000)
at com.android.server.accounts.AccountManagerService.startChooseAccountActivityWithAccounts(AccountManagerService.java:4503)
at android.app.ContextImpl.startActivityAsUser(ContextImpl.java:1000)
at com.android.server.accounts.AccountManagerService.startChooseAccountActivityWithAccounts(AccountManagerService.java:4503)
at com.android.server.accounts.AccountManagerService.handleGetAccountsResult(AccountManagerService.java:4512)
at com.android.server.accounts.AccountManagerService.handleGetAccountsResult(AccountManagerService.java:4512)
at com.android.server.accounts.AccountManagerService.access$2700(AccountManagerService.java:145)
at com.android.server.accounts.AccountManagerService.access$2700(AccountManagerService.java:145)
at com.android.server.accounts.AccountManagerService$19.onResult(AccountManagerService.java:4569)
at com.android.server.accounts.AccountManagerService$GetAccountsByTypeAndFeatureSession.sendResult(AccountManagerService.java:4187)
at com.android.server.accounts.AccountManagerService$GetAccountsByTypeAndFeatureSession.sendResult(AccountManagerService.java:4187)
at com.android.server.accounts.AccountManagerService$GetAccountsByTypeAndFeatureSession.checkAccount(AccountManagerService.java:4135)
at com.android.server.accounts.AccountManagerService$GetAccountsByTypeAndFeatureSession.checkAccount(AccountManagerService.java:4135)
at com.android.server.accounts.AccountManagerService$GetAccountsByTypeAndFeatureSession.onResult(AccountManagerService.java:4170)
at android.accounts.IAccountAuthenticatorResponse$Stub.onTransact(IAccountAuthenticatorResponse.java:104)
at android.os.Binder.execTransactInternal(Binder.java:1159)
at android.os.Binder.execTransact(Binder.java:1123)
at android.accounts.IAccountAuthenticatorResponse$Stub.onTransact(IAccountAuthenticatorResponse.java:104)
at android.os.Binder.execTransactInternal(Binder.java:1159)
at android.os.Binder.execTransact(Binder.java:1123)
Here is a short view of my manifest file :
<activity
android:name="com.google.android.apps.work.kerberosauthenticator.AuthenticatorStatusActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".DeclineAddingAccountActivity" android:exported="true"/>
<activity android:name=".ServiceTicketActivity" android:exported="true"/>
<activity android:name=".LoginActivity" android:exported="true"/>
Targetsdkversion is set to 30, what Activity / Permission needs to add for this startChooseAccountActivity ?
Thanks and Best Regards,
Andre

How to Disable a particular Intent-filter programmatically in Android?

I have a SplashScreen with 3 Intent-filters defined in Manifest like this -
<activity
android:name=".SplashScreen"
android:screenOrientation="portrait"
android:theme="#style/SplashTheme"
android:windowSoftInputMode="stateAlwaysHidden">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="kljb"
android:scheme="http" />
<data
android:host="kljb"
android:scheme="https" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- Accepts URIs that begin with "http://www.example.com/gizmos” -->
<data
android:host="xyz"
android:scheme="abc" />
</intent-filter>
</activity>
I want to disable this one -
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- Accepts URIs that begin with "http://www.example.com/gizmos” -->
<data
android:host="xyz"
android:scheme="abc" />
</intent-filter>
And After some user Action, I want to Enable it.
I have tried using -
PackageManager pm = getApplicationContext().getPackageManager();
ComponentName compName =
new ComponentName(getPackageName(), ".SplashScreen");
pm.setComponentEnabledSetting(
compName,
PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
PackageManager.DONT_KILL_APP);
I don't know exactly where to write this above code. I set this code in the oncreate of the SplashScreen but getting the error -
Unable to start activity ComponentInfo
java.lang.SecurityException: Attempt to change component state;
I know this question has been asked a number of times on SO but none of them is about where to write this code.
After Commonsware Suggestion:
I made an alias -
<activity-alias
android:name=".SplashScreen"
android:screenOrientation="portrait"
android:targetActivity=".SplashScreen"
android:theme="#style/SplashTheme"
android:windowSoftInputMode="stateAlwaysHidden">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- Accepts URIs that begin with "http://www.example.com/gizmos” -->
<data
android:host="xyz"
android:scheme="abc" />
</intent-filter>
</activity-alias>
So I am calling the code in the oncreate() of the MainActivity which opens after the SplashScreen -
2019-10-06 04:49:52.578 23014-23014/com.khaalijeb.inkdrops.debug
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.khaalijeb.inkdrops.debug, PID: 23014
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.khaalijeb.inkdrops.debug/com.khaalijeb.inkdrops.MainActivity}:
java.lang.SecurityException: Attempt to change component state;
pid=23014, uid=10262, component=com.khaalijeb.inkdrops/.SplashScreen
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3270)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3409)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
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:2016)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
Caused by: java.lang.SecurityException: Attempt to change component state; pid=23014, uid=10262,
component=com.khaalijeb.inkdrops/.SplashScreen
at android.os.Parcel.createException(Parcel.java:2071)
at android.os.Parcel.readException(Parcel.java:2039)
at android.os.Parcel.readException(Parcel.java:1987)
at android.content.pm.IPackageManager$Stub$Proxy.setComponentEnabledSetting(IPackageManager.java:7336)
at android.app.ApplicationPackageManager.setComponentEnabledSetting(ApplicationPackageManager.java:2554)
at com.khaalijeb.inkdrops.MainActivity.onCreate(MainActivity.java:1604)
at android.app.Activity.performCreate(Activity.java:7802)
at android.app.Activity.performCreate(Activity.java:7791)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1306)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3245)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3409) 
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83) 
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:2016) 
at android.os.Handler.dispatchMessage(Handler.java:107) 
at android.os.Looper.loop(Looper.java:214) 
at android.app.ActivityThread.main(ActivityThread.java:7356) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930) 
Caused by: android.os.RemoteException: Remote stack trace:
at com.android.server.pm.PackageManagerService.setEnabledSetting(PackageManagerService.java:21250)
at com.android.server.pm.PackageManagerService.setComponentEnabledSetting(PackageManagerService.java:21184)
at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:3473)
at com.android.server.pm.PackageManagerService.onTransact(PackageManagerService.java:4015)
at android.os.Binder.execTransactInternal(Binder.java:1021)
This is the same error I was getting.
So, I came to realize after a day of debugging and looking into the Android Developers' Documentation about the ComponentName.
I was implementing it in the debug mode and my packageName is - applicationId + suffix.
as you can see yours in build.gradle.
Previously, I was doing something like
PackageManager pm = getPackageManager();
ComponentName compName =
new ComponentName(this, getPackageName() + ".AliasSplashScreen");
pm.setComponentEnabledSetting(
compName,
PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
PackageManager.DONT_KILL_APP);
Now you see that I was using get package name() which is different for each build but My Class name has no effect due to this.
My class Name is and will always be originalpackagename.classname or more clearly applicationid.className. no matter the build variant(debug or release).
The Correct way is -
PackageManager pm = getPackageManager();
ComponentName compName =
new ComponentName(this, applicationid + ".AliasSplashScreen");
pm.setComponentEnabledSetting(
compName,
PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
PackageManager.DONT_KILL_APP);
And as CommonsWare pointed out you have to create an activity-alias in Android Manifest keeping the original one and targetActivity should be the one whose alias you are creating with the desired intent-filter inside that and use the above code to disable it in the onCreate() of the Next Activity and to enable it use PackageManager.COMPONENT_ENABLED_STATE_ENABLED

Runtime exception when launching an Activity from Chrome

I have configured one of my activities in my app to be be opened using a deep link like so:
<activity
android:name=".ui.barcodescanner.BarcodeScannerActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="com.company"
android:scheme="http"
android:pathPrefix="/myapp"/>
</intent-filter>
</activity>
This works as expected (my app launches with the correct activity) when chrome redirects to http://com.mycompany/myap on an API 27 Pixel 2 XL emulator. But I get the following error when I run it on my API 29 OnePlus 6:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.company.android.myapp/com.company.android.myapp.ui.login.IONLoginActivity}: android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3037)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3172)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1906)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6863)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:537)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
at android.app.ContextImpl.startActivity(ContextImpl.java:915)
at android.app.ContextImpl.startActivity(ContextImpl.java:891)
at android.content.ContextWrapper.startActivity(ContextWrapper.java:379)
at com.infor.authentication.AuthenticationManager.loadWebView(AuthenticationManager.java:712)
at com.infor.authentication.AuthenticationManager.showAuthenticationDialog(AuthenticationManager.java:1810)
at com.infor.authentication.AuthenticationManager.validateValuesAndStoreValues(AuthenticationManager.java:512)
at com.infor.authentication.AuthenticationManager.initiateAuthentication(AuthenticationManager.java:460)
at com.company.android.myapp.ui.login.IONLoginViewModel.authenticateWithION(IONLoginViewModel.java:26)
at com.company.android.myapp.ui.login.IONLoginActivity.onCreate(IONLoginActivity.java:36)
at android.app.Activity.performCreate(Activity.java:7149)
at android.app.Activity.performCreate(Activity.java:7140)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1288)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3017)
Why is this?

COSU: Cannot find Activity any more after pin and then restart

I'm developing an App that can be Screen Pinned aka Corporate Owned Single Use aka Lock Task Mode.
If I pin it and then:
I close it (killing it) and then I launch it again
or after some code modification in android studio and then perform Run
restart after pin and unpin
I get the following error:
[homtom-ht3_pro-0123456789ABCDEF]: E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.xx.yyy, PID: 7928
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.xx.yyy/com.xx.yyy.activities.LauncherActivity}: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.xx.yyy/com.xx.yy.activities.StartActivity}; have you declared this activity in your AndroidManifest.xml?
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2534)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2614)
at android.app.ActivityThread.access$800(ActivityThread.java:178)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1470)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5643)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.xx.yyy/com.xx.yyy.activities.StartActivity}; have you declared this activity in your AndroidManifest.xml?
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1788)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1512)
at android.app.Activity.startActivityForResult(Activity.java:3809)
at android.support.v4.app.BaseFragmentActivityJB.startActivityForResult(BaseFragmentActivityJB.java:50)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:79)
at android.app.Activity.startActivityForResult(Activity.java:3760)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:859)
at android.app.Activity.startActivity(Activity.java:4090)
at android.app.Activity.startActivity(Activity.java:4058)
at com.xx.yyy.activities.LauncherActivity.onCreate(LauncherActivity.java:16)
at android.app.Activity.performCreate(Activity.java:6099)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1112)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2481)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2614) 
at android.app.ActivityThread.access$800(ActivityThread.java:178) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1470) 
at android.os.Handler.dispatchMessage(Handler.java:111) 
at android.os.Looper.loop(Looper.java:194) 
at android.app.ActivityThread.main(ActivityThread.java:5643) 
at java.lang.reflect.Method.invoke(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:372) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755) 
This is my Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.xx.yyy">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<receiver
android:name=".receivers.DeviceAdminReceiver"
android:description="#string/app_name"
android:label="#string/app_name"
android:permission="android.permission.BIND_DEVICE_ADMIN">
<meta-data
android:name="android.app.device_admin"
android:resource="#xml/device_admin_receiver" />
<intent-filter>
<action android:name="android.intent.action.DEVICE_ADMIN_ENABLED" />
<action android:name="android.intent.action.PROFILE_PROVISIONING_COMPLETE" />
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<activity android:name=".activities.LauncherActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".activities.StartActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
If I don't ever pin the app I can restart/upgrade&run it many times I want.
The nice thing is that is not even possible to uninstall the app because it has been configured as Device Owner, and so, it cannot be uninstalled unless a factory reset.
I dont understand how is possible that my activity disappears after an app restart. Can be something related to the intent category or action?
If anyone else encountered this behavior can tell me I will submit an issue to the bug report site.
Thanks.
EDIT 18/3
I think maybe this is happening because at a certain point, I kill the home category activity that in my case is the missing StartActivity in question, and it is not restarted even if I restart the app.
Found the solution in my COSU disable pinning implementation, I was doing:
PackageManager mPackageManager = getApplicationContext().getPackageManager();;
mPackageManager.setComponentEnabledSetting(
new ComponentName(getApplicationContext(), StartActivity.class),
PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
PackageManager.DONT_KILL_APP);
to disable the pinning on device boot, but this actually disable the specified component.
The correct implementation would be:
PackageManager mPackageManager = getApplicationContext().getPackageManager();;
mPackageManager.setComponentEnabledSetting(
new ComponentName(getApplicationContext(), StartActivity.class),
PackageManager.COMPONENT_ENABLED_STATE_DEFAULT,
PackageManager.DONT_KILL_APP);

Categories

Resources