如何从Receiver in Service接收日期?

时间:2017-06-10 01:40:10

标签: android

我想在Receiver中发送日期并在服务中接收日期,但服务中的Intent没有date.blew是代码。任何人都知道该怎么办?要求很简单,但它不能按我的意愿工作......

//的AndroidManifest.xml

<service android:name=".AlarmService"/>
<activity android:name=".AlarmActivity"/>

//接收机

@Override
    public void onReceive(Context context, Intent intent) {
        Intent musicService = new Intent(context, AlarmService.class);
        intent.putExtra("requestCode",1024);
        context.startService(musicService);
    }

//服务

@Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        int requestCode = intent.getIntExtra("requestCode", 0);
        Log.e("AlarmService", "onStartCommand: " + requestCode);
        return super.onStartCommand(intent, flags, startId);
    }

// LOG

06-10 09:33:49.923 6498-6498/kingja.alarm.guider E/AlarmService: onStartCommand: 0

0 个答案:

没有答案