在启动时启动并启动 URI 请求以启动其他应用的 Android 服务



我需要编写一个服务,该服务在设备启动时启动并启动URI以启动另一个应用程序。我的研究表明我必须使用广播接收器,但我是安卓的新手。请为我提供一些源代码,或指出我一个有用的方向。

非常感谢

这是侦听设备启动完成操作、接收广播消息和启动服务的方法。

安卓清单.xml

<receiver android:name=".DeviceBootListener">
    <intent-filter android:priority="0">
        <action android:name="android.intent.action.BOOT_COMPLETED" />
    </intent-filter>
</receiver>

广播接收器:

public class DeviceBootListener extends BroadcastReceiver 
{
@Override
public void onReceive(Context context, Intent intent) 
{
    Intent myService = new Intent(context, MyService.class);
    context.startService(myService);
}
}

最新更新