}
} else {
appName = getIntent().getStringExtra("app_name");
-
- if(getResources().getConfiguration().smallestScreenWidthDp >= 600
- && Build.VERSION.SDK_INT <= Build.VERSION_CODES.M)
- setTitle(appName);
- else {
- addPreferencesFromResource(R.xml.pref_context_menu_header);
- findPreference("header").setTitle(appName);
- }
+ addPreferencesFromResource(R.xml.pref_context_menu_header);
+ findPreference("header").setTitle(appName);
final PackageManager pm = getPackageManager();
Intent homeIntent = new Intent(Intent.ACTION_MAIN);
import android.app.Activity;
import android.app.admin.DevicePolicyManager;
+import android.content.ActivityNotFoundException;
import android.content.ComponentName;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
+import android.widget.Toast;
import com.farmerbb.taskbar.R;
import com.farmerbb.taskbar.receiver.LockDeviceReceiver;
Intent intent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, new ComponentName(this, LockDeviceReceiver.class));
intent.putExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION, getString(R.string.device_admin_description));
- startActivity(intent);
+
+ try {
+ startActivity(intent);
+ } catch (ActivityNotFoundException e) {
+ Toast toast = Toast.makeText(this, getString(R.string.lock_device_not_supported), Toast.LENGTH_SHORT);
+ toast.show();
+
+ finish();
+ }
} else finish();
}
}
<string name="device_admin_description_short">Allows Taskbar to lock this device via the start menu</string>
<string name="device_admin_description">Allows Taskbar to lock this device via the start menu.\n\nThis will require you to deactivate Taskbar as a device administrator prior to installing.</string>
+ <string name="lock_device_not_supported">Not supported on this device</string>
<string name="pref_title_shortcut_icon">Show shortcut icon for pinned apps</string>