关闭应用程序后如何在特定时间启动应用程序

时间:2019-05-04 16:30:32

标签: android alarm

我需要制作一个在自定义选定时间打开的警报应用程序(即使关闭该应用程序也会在屏幕上显示)。使用警报管理器/广播接收器,我设法显示了通知,但没有启动该应用程序。

1 个答案:

答案 0 :(得分:0)

您可以从广播接收机开始任何这样的活动:

<style>
    #contexmenu{
        display: none;
        position: relative;
        width: 100px;
        background: rgb(238, 238, 238);}
        #contexmenu section{
            padding: 5px;}
        #contexmenu section:hover{
            background-color: rgb(219, 219, 219)}
    #mainarea{
        width: 100vw;
        height: calc(100vh - 50px);
        background: red;
    }
</style>

<article id="contexmenu">
    <section onclick="addJob()">Add Job</section>
    <section>Edit Job</section>
    <section>Refresh</section>
</article>

<article id="mainarea">

</article>

<script>

function addJob(){
    alert("");
}

document.addEventListener("contextmenu", function(event){
    event.preventDefault();
    var contexmenu = document.getElementById("contexmenu")
    contexmenu.style.display = "block";
    contexmenu.style.top = `${event.screenY - 50 - contexmenu.clientHeight}px`;
    contexmenu.style.left = `${event.screenX - 65}px`;
    console.log("New event");
})

document.addEventListener("click", function(event){
    document.getElementById("contexmenu").style.display = "none";
})
</script>