I'm trying to create a shortcut on the home screen that, when pressed, will start a service instead of an activity.
Is it possible? How?
Thanks!
Press the Win + R keys on your keyboard, to open the Run window. Then, type "services. msc" and hit Enter or press OK.
Enable service Open Start. Search for Command Prompt, right-click the top result, and select the Run as administrator option. Type the following command to enable a service and press Enter: sc config "SERVICE-NAME" start=auto In the command, replace "SERVICE-NAME" for the name of the service that you want to enable.
The first method you can use to launch it is the run command. Press Windows key + R then type: control then hit Enter. Voila, the Control Panel is back; you can right-click on it, then click Pin to Taskbar for convenient access. Another way you can access the Control Panel is from within File Explorer.
You can create a dummy Activity that simply starts a Service, then finishes itself:
public class MyServiceActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = new Intent(this, MyService.class);
startService(intent);
finish();
}
}
No, sorry. Shortcuts only launch activities.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With