OneSignal Notification Click Crashes App - ActivityNotFoundException - android

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)

Related

firebase dynamic link causes ActivityNotFoundException on targetSdk 33

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">

Enable/Disable android.nfc.action.TECH_DISCOVERED IntentFilter

I'd like to disable android.nfc.action.TECH_DISCOVERED IntentFilter depending on users' settings choice,
to avoid the choosing app dialog shows up.
In order to do this, I've created an activity-alias in my Android Manifest file and change its state through PackageManager:
Anroid Manifest File
<activity
android:name=".activities.ActivitySplash"
android:configChanges="orientation"
android:label="#string/app_name"
android:launchMode="singleTask"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity-alias
android:name=".AliasActivitySplash"
android:targetActivity=".activities.ActivitySplash"
android:exported="true"
android:enabled="true">
<intent-filter>
<action android:name="android.nfc.action.TECH_DISCOVERED"/>
</intent-filter>
<meta-data
android:name="android.nfc.action.TECH_DISCOVERED"
android:resource="#xml/techlist"/>
</activity-alias>
Activity Alias State Management:
public void enableAlias() {
int newState = PackageManager.COMPONENT_ENABLED_STATE_ENABLED;
_packageManager.setComponentEnabledSetting(new ComponentName(_packageName, _packageName + "." +
"AliasActivitySplash"), newState, PackageManager.DONT_KILL_APP);
}
public void disableAlias() {
int newState = PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
_packageManager.setComponentEnabledSetting(new ComponentName(_packageName, _packageName + "." +
"AliasActivitySplash"), newState, PackageManager.DONT_KILL_APP);
}
I get a java.lang.SecurityException everytime i try to change the alias state. I've read installing the app as a system app should solve the issue.
Exception caught:
java.lang.SecurityException: Attempt to change component state; pid=10766, uid=10329, component=packagename/packagename.AliasActivitySplash
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 packagename.activities.alias.ActivitySplashAliasManager.disableAlias(ActivitySplashAliasManager.java:27)
at packagename.fragments.FragmentPreferences.onPreferenceChange(FragmentPreferences.java:83)
at androidx.preference.Preference.callChangeListener(Preference.java:1118)
at androidx.preference.TwoStatePreference.onClick(TwoStatePreference.java:67)
at androidx.preference.Preference.performClick(Preference.java:1182)
at androidx.preference.Preference.performClick(Preference.java:1166)
at androidx.preference.SwitchPreferenceCompat.performClick(SwitchPreferenceCompat.java:193)
at androidx.preference.Preference$1.onClick(Preference.java:181)
at android.view.View.performClick(View.java:7140)
at android.view.View.performClickInternal(View.java:7117)
at android.view.View.access$3500(View.java:801)
at android.view.View$PerformClick.run(View.java:27351)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
2019-10-24 09:21:43.863 10766-10766/packagename E/Test: 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)
Am I doing something wrong or is there any other way to do this?
I've finally solved it. The problem was the way I was getting the packagename. My app has multiple flavor configuration and i was trying to disable/enable a component from the other flavor installed on my device

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?

Google Analytics service Intent crashes on Android Oreo

I have upgraded my app to support SDK 26 and now Google Analytics causes crashes when running on Android Oreo:
Fatal Exception: java.lang.RuntimeException: Unable to start receiver
com.google.android.gms.analytics.AnalyticsReceiver:
java.lang.IllegalStateException: Not allowed to start service Intent {
act=com.google.android.gms.analytics.ANALYTICS_DISPATCH
cmp=com.example.android/com.google.android.gms.analytics.AnalyticsService
}: app is in background uid UidRecord{3f302e5 u0a107 RCVR idle procs:1
seq(0,0,0)}
at android.app.ActivityThread.handleReceiver(ActivityThread.java:3259)
at android.app.ActivityThread.-wrap17(Unknown Source)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1677)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767) Caused by java.lang.IllegalStateException: Not allowed to start
service Intent {
act=com.google.android.gms.analytics.ANALYTICS_DISPATCH
cmp=com.example.android/com.google.android.gms.analytics.AnalyticsService
}: app is in background uid UidRecord{3f302e5 u0a107 RCVR idle procs:1
seq(0,0,0)}
at android.app.ContextImpl.startServiceCommon(ContextImpl.java:1505)
at android.app.ContextImpl.startService(ContextImpl.java:1461)
at android.content.ContextWrapper.startService(ContextWrapper.java:644)
at android.content.ContextWrapper.startService(ContextWrapper.java:644)
at com.google.android.gms.internal.zzaot.onReceive(Unknown Source:68)
at com.google.android.gms.analytics.AnalyticsReceiver.onReceive(Unknown
Source:11)
at android.app.ActivityThread.handleReceiver(ActivityThread.java:3252)
at android.app.ActivityThread.-wrap17(Unknown Source)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1677)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
This is my relevant Manifest:
<meta-data
android:name="com.google.android.gms.analytics.globalConfigResource"
android:resource="#xml/analytics"/>
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version"/>
<!-- Optionally, register AnalyticsReceiver and AnalyticsService to support background
dispatching on non-Google Play devices -->
<receiver
android:name="com.google.android.gms.analytics.AnalyticsReceiver"
android:enabled="true">
<intent-filter>
<action android:name="com.google.android.gms.analytics.ANALYTICS_DISPATCH"/>
</intent-filter>
</receiver>
<service
android:name="com.google.android.gms.analytics.AnalyticsService"
android:enabled="true"
android:exported="false"/>
<!-- Optionally, register CampaignTrackingReceiver and CampaignTrackingService to enable
installation campaign reporting -->
<receiver
android:name="com.google.android.gms.analytics.CampaignTrackingReceiver"
android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER"/>
</intent-filter>
</receiver>
<service
android:name="com.google.android.gms.analytics.CampaignTrackingService"
android:exported="true"/>
Having hundreds of Oreo devices crashing due to this in past 24 hours. Seems to be affecting only on install. I am going to try and add android:permission="android.permission.BIND_JOB_SERVICE" to the 2 analytics services and see. Will report.
I Will be happy to provide more info if needed. Thanks
I recommend upgrading to play-services version 11.4.0. Add this in your Gradle file:
compile "com.google.android.gms:play-services-analytics:11.4.0
From the Play Services Revision 11.4.0, analytics section:
Added a new class AnalyticsJobService. This class provides compatibility support for Android O and is used by Analytics to upload data. No action is necessary to use this class, it’s added automatically as part of the Analytics package.
Deprecated the getContext() method of the AnalyticsService class.
Deprecated the CampaignTrackingService class.
and also you have to get permission.
android:permission="android.permission.BIND_JOB_SERVICE"
See below
https://developers.google.com/android/reference/com/google/android/gms/analytics/AnalyticsJobService
because CampaignTrackingService is now Deprecated
just remove this line from your manifest
<service android:name="com.google.android.gms.analytics.CampaignTrackingService"
android:exported="true"/>

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