SCREEN_BRIGHTNESS_MODE does not work with permission - android

In my app I want to change the SCREEN_BRIGHTNESS_MODE (and set another value). I added the permission in the AndroidManifest.xml (double checked with other parameters in the file). The value of the mode should be changed, when a button was pressed.
#Override
public void onClick(View v) {
if(on) {
ContentResolver cResolver = getContentResolver();
Settings.System.putInt(cResolver, Settings.System.SCREEN_BRIGHTNESS_MODE, Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL);
Settings.System.putInt(cResolver, Settings.System.SCREEN_BRIGHTNESS, 50);
}
}
And the AndroidManifest.xml:
<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
<activity
android:name=".FullscreenActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="#string/app_name"
android:screenOrientation="landscape"
android:theme="#style/FullscreenTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
The Android device is a Logic Instrument Fieldbook F1 Android-Version 5.0.1
When I try to execute this command I got the following Exception:
08-31 15:29:28.471 16613-16613/com.matodayu.oxo E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.matodayu.oxo, PID: 16613 java.lang.SecurityException: Permission denial: writing to settings requires android.permission.WRITE_SETTINGS
at android.os.Parcel.readException(Parcel.java:1540)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:190)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:142)
at android.content.ContentProviderProxy.call(ContentProviderNative.java:643)
at android.provider.Settings$NameValueCache.putStringForUser(Settings.java:1094)
at android.provider.Settings$System.putStringForUser(Settings.java:1371)
at android.provider.Settings$System.putIntForUser(Settings.java:1476)
at android.provider.Settings$System.putInt(Settings.java:1470)
at com.matodayu.oxo.FullscreenActivity$4$1.run(FullscreenActivity.java:184)
at android.app.Activity.runOnUiThread(Activity.java:5285)
at com.matodayu.oxo.FullscreenActivity$4.onClick(FullscreenActivity.java:179)
at android.view.View.performClick(View.java:4809)
at android.view.View$PerformClick.run(View.java:20123)
at android.os.Handler.handleCallback(Handler.java:815)
at android.os.Handler.dispatchMessage(Handler.java:104)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5534)
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:955)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:750)
Can anyone help me?

Where did you defined your permissions?
Inside the manifest or application tag?
I made a Test-Project and it works.
It just failed when i added the permission inside the wrong position - e.g. the application tag.

Related

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

Android: Amplify SignOut closes app before actually signin out

I decided to use Amplify on a school project, after I went through the Login process following this guide: https://docs.amplify.aws/lib/auth/signin/q/platform/android/
And also after adding the social sign in: https://docs.amplify.aws/lib/auth/social_signin_web_ui/q/platform/android/
After following these guides I decided to also add a signout feature and test it out: https://docs.amplify.aws/lib/auth/signOut/q/platform/android/
It should have worked fine but when i lauch the signout method in the guide (literally after copying and pasting it in the project) the app closes as soon as I test it, and it isn't even consistent with the errors, the usual pattern is: it closes, after a while the console says that the signout timed out (obviously) when I reopen the app from the VM it says that it signout successfully then crashes giving this error (the project is called natour):
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.natour, PID: 7330
java.lang.RuntimeException: Unable to resume activity {com.example.natour/com.amazonaws.mobileconnectors.cognitoauth.activities.CustomTabsManagerActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.content.Intent.migrateExtraStreamToClipData()' on a null object reference
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3400)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3440)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2713)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.content.Intent.migrateExtraStreamToClipData()' on a null object reference
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1516)
at android.app.Activity.startActivityForResult(Activity.java:4224)
at android.app.Activity.startActivityForResult(Activity.java:4183)
at android.app.Activity.startActivity(Activity.java:4507)
at android.app.Activity.startActivity(Activity.java:4475)
at com.amazonaws.mobileconnectors.cognitoauth.activities.CustomTabsManagerActivity.onResume(CustomTabsManagerActivity.java:69)
at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1269)
at android.app.Activity.performResume(Activity.java:6766)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3377)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3440)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2713)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
I tried different things, thinking that if the login worked just fine, then something weird happened for the logout redirect uri, but nope, i changed it with "amplify update auth" on the console, changed the callback uri and nothing appened, the same error, the login worked just fine too even though I wrote an activity that wasn't even launched.
I changed the manifest because maybe the custom tab manager activity gave problems but to no avail (meaning it either gives far worse problems to which I know the cause or the same)
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.natour">
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" tools:ignore="QueryAllPackagesPermission" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission
android:name="android.permission.GET_ACCOUNTS"
android:maxSdkVersion="22" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<queries>
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="natour" />
</intent>
<intent>
<action android:name="android.support.customtabs.action.CustomTabsService" />
</intent>
</queries>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/Theme.NaTour">
<activity
android:name=".view.TransazioneRegister"
android:exported="false" />
<activity
android:name=".visualizza_foto_inserite"
android:exported="false" />
<activity
android:name=".visualizza_segnalazioni_effettuate"
android:exported="false" />
<activity
android:name=".visualizza_itinerari_inseriti"
android:exported="false" />
<activity
android:name=".visualizza_recensioni_inserite"
android:exported="false" />
<activity
android:name=".view.InserimentoItinerario"
android:exported="false" />
<activity
android:name=".view.Profile"
android:exported="false" />
<activity
android:name=".view.Register"
android:exported="false" />
<activity
android:name=".view.Login"
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=".view.VisualizzaItinerario"
android:exported="false" />
<activity
android:name=".view.TabActivity"
android:exported="false" /> <!-- Facebook Requirements -->
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="#string/facebook_app_id" />
<activity
android:name="com.amplifyframework.auth.cognito.activities.HostedUIRedirectActivity"
android:exported="true">
<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:scheme="natour"/>
</intent-filter>
</activity>
<activity
android:name=".view.Signout"
android:exported="true">
<intent-filter>
<data android:scheme="natour"/>
</intent-filter>
</activity>
<!--<activity
android:name="com.amazonaws.mobileconnectors.cognitoauth.activities.CustomTabsRedirectActivity"
android:exported="true">
<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:scheme="natour" />
</intent-filter>
</activity>-->
</application>
</manifest>
this is the manifest in the final attempt, after that i gave up.
I searched this problem online and even though they got pretty close to our problem, either they didn't show the solution, the code is written in other programming language, they didn't explain what was going on. I hope to find some help here, thanks in advance.
I know this has been a while but I found that you need to change launchMode. I tried singleTask it works fine. Maybe singleInstance also works. But I get a time out error: Timed out while waiting for sign-out redirect response.
I found amplify is difficult to deal with because lack of documents and potential bugs, maybe also because not many people use it.

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

Trying to connect Firebase plus FB Auth and get error

Trying to connect FB Auth to Firebase. Appears error
FATAL EXCEPTION: main
Process: com.borisruzanov.social, PID: 20684
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.borisruzanov.social/com.borisruzanov.social.FacebookLoginActivity}: A valid Facebook app id must be set in the AndroidManifest.xml or set by calling FacebookSdk.setApplicationId before initializing the sdk.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2665)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: A valid Facebook app id must be set in the AndroidManifest.xml or set by calling FacebookSdk.setApplicationId before initializing the sdk.
at com.facebook.FacebookSdk.sdkInitialize(FacebookSdk.java:276)
at com.facebook.FacebookSdk.sdkInitialize(FacebookSdk.java:232)
at com.borisruzanov.social.FacebookLoginActivity.onCreate(FacebookLoginActivity.java:49)
at android.app.Activity.performCreate(Activity.java:6679)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618
Here is my manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.borisruzanov.social">
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".AuthPage">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".GoogleSignInActivity" >
</activity>
<activity android:name=".PhoneAuthActivity" >
</activity>
<activity android:name=".FacebookLoginActivity"
>
<meta-data android:name="com.facebook.sdk.ApplicationId"
android:value="#string/facebook_app_id"/>
</activity>
<activity android:name="com.facebook.FacebookActivity"
android:configChanges=
"keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="#string/app_name" />
<activity
android:name="com.facebook.CustomTabActivity"
android:exported="true">
<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:scheme="#string/fb_login_protocol_scheme" />
</intent-filter>
</activity>
</application>
</manifest>
And also i dont understand why initialization of SDK is not actual and it stroked. I have tried solutions which on stack. Doesn't help.
Also if any1 know the good example where Firebase and Facebook auth integrated well? Because as always firebase guide is totally collapsed my brain.
You need add
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//initialize Facebook SDK
FacebookSdk.sdkInitialize(getApplicationContext());
if (BuildConfig.DEBUG) {
FacebookSdk.setIsDebugEnabled(true);
FacebookSdk.addLoggingBehavior(LoggingBehavior.INCLUDE_ACCESS_TOKENS);
}
setContentView(R.layout.activity_main); }
Need add meta-data to Application
<application android:label = "#string/app_name" ... >
...
<meta-data android:name = "com.facebook.sdk.ApplicationId" android:value = "#string/facebook_app_id" />
...
</ application>
instead of
<activity android:name=".FacebookLoginActivity"
>
<meta-data android:name="com.facebook.sdk.ApplicationId"
android:value="#string/facebook_app_id"/>
</activity>
You don't really need to initialize FacebookSDK manually as it gets initialized automatically, just change your manifest file as #Boris showed. Hope it will work now.

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