I am getting this error on my huawei nexus 6p while putting the app in protected apps list.
"UncaughtException: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.huawei.systemmanager/com.huawei.systemmanager.optimize.process.ProtectActivity}; have you declared this activity in your AndroidManifest.xml?"
and i am using this code to put the app in protected apps list
if ("huawei".equalsIgnoreCase(Build.MANUFACTURER) && !settingsManager.getKeyStateProtectedApp()) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Is app killing?").setMessage("Add LastingSales to protected apps list to keep it running in background.")
.setPositiveButton("YES", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
Intent intent = new Intent();
intent.setComponent(new ComponentName("com.huawei.systemmanager", "com.huawei.systemmanager.optimize.process.ProtectActivity"));
startActivity(intent);
settingsManager.setKeyStateProtectedApp(true);
}
}).create().show();
}
Problem here is that this is not an activity of my own that i can declare in manifest. Do i still have to declare it in manifest ? if i do have to then how can i do this ?
SOLVED the reason was that huawei nexus 6p has pure android and hence there is no such activity. but code was falling there because Build.MANUFACTURER returns "huawei". however Build.BRAND returns "google" so added additional check as
if ("huawei".equalsIgnoreCase(Build.MANUFACTURER) && !"google".equalsIgnoreCase(Build.BRAND) && !settingsManager.getKeyStateProtectedApp()