1
我正在嘗試編寫一個簡單的應用程序,並遵循ApiDemos示例。我的應用程序在啓動時崩潰。我懷疑我的清單存在問題,但我不確定。請有任何想法嗎?以管理員身份運行Android應用程序
public class managerActivity extends DeviceAdminReceiver {
public class Controller extends Activity {
static final int RESULT_ENABLE = 1;
DevicePolicyManager mDPM;
ActivityManager mAM;
ComponentName mDeviceAdminSample;
Button mEnableButton;
Button mDisableButton;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mDPM = (DevicePolicyManager)getSystemService(Context.DEVICE_POLICY_SERVICE);
mAM = (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
mDeviceAdminSample = new ComponentName(Controller.this, managerActivity.class);
setContentView(R.layout.main);
}
}
,然後在我的表現,我有:
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name="com.appname.managerActivity$Controller"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
<action android:name="android.app.action.DEVICE_ADMIN_ENABLED" />
</intent-filter>
</activity>
<!-- Device Admin Samples -->
<receiver android:name="com.appname.managerActivity"
android:label="@string/sample_device_admin"
android:description="@string/sample_device_admin_description"
android:permission="android.permission.BIND_DEVICE_ADMIN">
<meta-data android:name="android.app.device_admin"
android:resource="@xml/device_admin_sample" />
<intent-filter>
<action android:name="android.app.action.DEVICE_ADMIN_ENABLED" />
</intent-filter>
</receiver>
這裏的崩潰:
11-11 15:20:52.310:ERROR/AndroidRuntime(553): java.lang.RuntimeException:無法實例化活動 ComponentInfo {com.appname.manager/com.appname.managerActivity $ Controller}: java.lang.InstantiationException: com.appname.managerActivity $控制器
使其靜態工作很好。我很高興這很簡單。謝謝! –