从Broadcastreceiver问题调用服务

时间:2015-03-16 15:36:30

标签: android

我需要在broadcastreceiver中使用一个服务(我从一个告警管理器启动接收器)但问题是我需要调用该服务时。显然这从未被执行过。我也设置调试器来检查,但这也永远不会附加到代码。

我不知道为什么服务永远不会被触发

我的接收者电话

 private void getHour()
    {
        // use this to start and trigger a service
        Intent i = new Intent( context, getHourService.class );
        i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startService( i );
    }

服务

public class getHourService extends Service
{
    public int horaR;
    public int minR;

    @Override
    public int onStartCommand( Intent intent, int flags, int startId )
    {
        android.os.Debug.waitForDebugger();

        // Some logical code here  
    }
}

我添加了清单

   <application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >

    <activity
        android:name=".MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <!-- Lot of Receivers -->

    <!-- Service -->
    <service android:name="alarmas.getHourService" > </service>

</application>

0 个答案:

没有答案
相关问题