Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Okay, I'm pretty sure that this is not possible but a client had asked me to do so in one of our Android application we developed for her.

What she had wanted is that if our application is running, and user navigate to:

 Settings > Manage Application > [Our Application]

, the button for "Force Stop" is disabled.

Is this possible? If it is possible, could someone point me out which way I should walk, or if it is not possible, how, using a valid argument based on facts, should I break the news to her.

Update: She just sent me a screenshot that, in her opinion, validates her request that there's an Android application that disables "Force Stop" button. How am I supposed to explain this to her?

Evernote Launcher - Force Stop disabled

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
425 views
Welcome To Ask or Share your Answers For Others

1 Answer

How to disable the "Force Stop" button

Short answer: Use the Device Administration API.

How to explain this to my client?

Show this to your client. It is a nice slideshow providing an easy-to-understand overview of the Device Administration API and its uses.

How do I demonstrate that it works?

Yes, back to your job. Use the API link provided above and the Api Demos included in Google's sample collection to figure out how to integrate this into your app.

  1. Build the demo and run it on your device.
  2. Choose API Demos->App->Device Admin->General->Enable admin.
  3. Choose Activate once the Device Administration API prompts you with its enabling screen.
  4. Exit the app and attempt to manage the app via your device's settings menu (specifics for this step varies by device).
  5. When viewing the Api Demo's "app info" screen, you should see both Force Stop and Uninstall are disabled.

How do I do this in my own app?

Review DeviceAdminSample.java in the Api Demos app for inspiration. You will need the following:

The following code is what brings up the activation screen:

                        // Launch the activity to have the user enable our admin.
                    Intent intent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
                    intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, mDeviceAdminSample);
                    intent.putExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION,
                            mActivity.getString(R.string.add_admin_extra_app_text));
                    startActivityForResult(intent, REQUEST_CODE_ENABLE_ADMIN);

However, there are a few other pieces you will need to get this to work:

  1. A broadcast receiver that derives from DeviceAdminReceiver.
  2. Entries in your manifest file that refer to the above broadcast receiver.
  3. Permissions in your manifest for using the Device Administrator API.
  4. An xml file stating what policies your app can access.

All of this can be found in the above links. Good luck with your client!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...