重启后,Alarm Manager未调用Service

时间:2015-11-03 12:16:19

标签: android alarmmanager

我有一个警报管理器,每1分钟调用一次特定服务,进行一些计算并向广播接收器发送广播。我使用报警管理器setRepeating()完成了这个。

这是我的代码:

警报管理员:

    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>

它工作正常但重启手机后,报警管理器没有调用该服务。

我在互联网上搜索并找到了一些像下面这样的解决方案,但它们对我没用。

我还提供了Boot Complete权限

    <receiver
        android:name=".NotificationReceiver"
        android:enabled="true"
        android:exported="true" >

           <action android:name="android.intent.action.BOOT_COMPLETED" />

    </receiver>

我的接收者在清单中:

            <div class="container">
            <div class="top-ribbon-outer">
                <div class="top-ribbon-inner">
                     <h1>first last</h1>

                    <nav>
                        <ul>
                            <li>item1</li>
                            <li>item2</li>
                            <li>item3</li>
                            <li>item4</li>
                        </ul>
                    </nav>
                </div>
            </div>
        </div>
        <div class="wrapper">
            <div id="boks1">
                <div class="innhold topboks">
        <span> 
         <p>
Lorem dummy text of the printing and typesetting industry. 
 Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, 
when an unknown printer took a galley of type and scrambled it to make a type specimen book. 
    It has survived not only five centuries, but also the leap into electronic typesetting,
 remaining essentially unchanged. 
    It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, 
and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
      </p>
         <img src="http://www.w3schools.com/cssref/img_tree.gif" alt="" />   
         </span>
         </div>
        </div>
      <div class="innhold boks">
         <span> 
            <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. 
    Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, 
when an unknown printer took a galley of type and scrambled it to make a type specimen book.
 It has survived not only five centuries, but also the leap into electronic typesetting, 
remaining essentially unchanged.
 It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, 
and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
          </p>
         <img src="http://www.w3schools.com/cssref/img_tree.gif" alt="" />  
         </span>
     </div>
      <div class="innhold boks">
        <span>
           <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. 
    Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
 It has survived not only five centuries, but also the leap into electronic typesetting, 
remaining essentially unchanged. 
    It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, 
and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
        </p>
         <img src="http://www.w3schools.com/cssref/img_tree.gif" alt="" />       
        </span>
       </div>
        <div class="innhold boks">
          <span>  
          <p>Lorem Ipsum is simply dummy text of the printing 
      and typesetting industry. 
    Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, 
when an unknown printer took a galley of type and scrambled it to make a type specimen book. 
    It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. 
    It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, 
and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
       </p>
       <img src="http://www.w3schools.com/cssref/img_tree.gif" alt="" />   
      </span>
      </div>

          <div id="kontakt">
                <!-- will be a footer with contact information etc.-->
            </div>

    </div>

任何人都可以告诉我如何解决这个问题吗?

1 个答案:

答案 0 :(得分:0)

你的broadCast应该开始服务,而不是alarmManager。

1)引导设备 2)从bootReceiver启动服务 3)在服务中启动alarmManager。

希望它有所帮助。