public class lock extends DeviceAdminReceiver {
public static class Controller extends Activity {
DevicePolicyManager mDPM;
ComponentName mDeviceAdminSample;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mDPM = (DevicePolicyManager)getSystemService(Context.DEVICE_POLICY_SERVICE);
mDeviceAdminSample = new ComponentName(Controller.this,
lock.class);
boolean active = mDPM.isAdminActive(mDeviceAdminSample);
if (active)
{
mDPM.lockNow();
}
}
}
}
我面临的错误是:
1.04-11 18:25:50.918: ERROR/AndroidRuntime(860): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.lock/com.lock.lock.Controller}: java.lang.ClassNotFoundException: com.lock.lock.Controller in loader
dalvik.system.PathClassLoader[/data/app/com.lock-1.apk]
04-11 18:25:50.918: ERROR/AndroidRuntime(860): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
04-11 18:25:50.918: ERROR/AndroidRuntime(860): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
04-11 18:25:50.918: ERROR/AndroidRuntime(860): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
04-11 18:25:50.918: ERROR/AndroidRuntime(860): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
04-11 18:25:50.918: ERROR/AndroidRuntime(860): at android.os.Handler.dispatchMessage(Handler.java:99)
04-11 18:25:50.918: ERROR/AndroidRuntime(860): at android.os.Looper.loop(Looper.java:123)
04-11 18:25:50.918: ERROR/AndroidRuntime(860): at android.app.ActivityThread.main(ActivityThread.java:4627)
04-11 18:25:50.918: ERROR/AndroidRuntime(860): at java.lang.reflect.Method.invokeNative(Native Method)
04-11 18:25:50.918: ERROR/AndroidRuntime(860): at java.lang.reflect.Method.invoke(Method.java:521)
04-11 18:25:50.918: ERROR/AndroidRuntime(860): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-11 18:25:50.918: ERROR/AndroidRuntime(860): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-11 18:25:50.918: ERROR/AndroidRuntime(860): at dalvik.system.NativeStart.main(Native Method)
04-11 18:25:50.918: ERROR/AndroidRuntime(860): Caused by: java.lang.ClassNotFoundException: com.lock.lock.Controller in loader dalvik.system.PathClassLoader[/data/app/com.lock-1.apk]
04-11 18:25:50.918: ERROR/AndroidRuntime(860): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
04-11 18:25:50.918: ERROR/AndroidRuntime(860): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
04-11 18:25:50.918: ERROR/AndroidRuntime(860): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
04-11 18:25:50.918: ERROR/AndroidRuntime(860): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
04-11 18:25:50.918: ERROR/AndroidRuntime(860): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
04-11 18:25:50.918: ERROR/AndroidRuntime(860): ... 11 more