I can call my function on the click of a button with no issues like this and it works, also wipes data.
public class MainActivity extends Activity implements OnCheckedChangeListener {
DevicePolicyManager devicePolicyManager;
public void resetdevice(View view) {
Toast.makeText(context, "resetttt", Toast.LENGTH_LONG).show();
// We reset the device - this will erase entire /data partition!
Log.d(TAG,
"RESETing device now - all user data will be ERASED to factory settings");
devicePolicyManager.wipeData(ACTIVATION_REQUEST);
}
but, in order to call this method from another service, i need to do some changes.
public class MainActivity extends Activity implements OnCheckedChangeListener {
static DevicePolicyManager devicePolicyManager;
and my method
public static void resetdevice(Context context) {
Toast.makeText(context, "resetttt", Toast.LENGTH_LONG).show();
// We reset the device - this will erase entire /data partition!
Log.d(TAG,
"RESETing device now - all user data will be ERASED to factory settings");
devicePolicyManager.wipeData(ACTIVATION_REQUEST);
}
here is how i call it
MainActivity.resetdevice(context);
the problem is, when calling it from my service, it only shows toast, and doesn't execute rest of the code.