Note that there are some explanatory texts on larger screens.

plurals
  1. POjava.lang.SecurityException: No active admin owned by uid 10034 for policy #3
    primarykey
    data
    text
    <p>I create a lock screen widget app recently. It always has the exception:</p> <pre><code>( java.lang.SecurityException: No active admin owned by uid 10034 for policy #3) </code></pre> <p>I try many methods and can not eliminate the exception. I open the activity to realize the purpose of the lock screen when the condition was founded.</p> <pre><code>public class tempActivity extends Activity { private static final String TAG = "tempActivity"; private DevicePolicyManager policyManager; private ComponentName componentName; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.temp); Log.e(TAG, "Activity created~"); policyManager = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE); componentName = new ComponentName(this, AdminReceiver.class); mylock(); } private void mylock() { boolean active = policyManager.isAdminActive(componentName); if (!active) { // Without permission Log.e(TAG, "No authority~"); activeManage(); // To get access policyManager.lockNow(); // And lock screen } else { Log.e(TAG, "Has authority"); policyManager.lockNow(); // lock screen directly } this.finish(); } private void activeManage() { Log.e(TAG, "activeManage"); Intent intent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN); intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, componentName); intent.putExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION, "developers:liushuaikobe"); startActivityForResult(intent, 1); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload