大家好,我如何在从服务接收意图以及一些 int 和 string 类型参数的活动中实现广播接收器?
更新:
我在活动下有这个:
private BroadcastReceiver ReceivefrmSERVICE = new BroadcastReceiver(){
@Override
public void onReceive(Context context, Intent intent) {
Toast.makeText(context, "IN DA BroadCASTER",
Toast.LENGTH_LONG).show();
}
};
我将此在服务中的功能下进行,该功能在检查检查按钮时从另一个活动中调用事件:
public void switchSpeaker(int hr, int min){
Toast.makeText(Server.this, hr +" , " +min, Toast.LENGTH_LONG).show();
Intent intent = new Intent(this, andRHOME.class);
//intent.putExtra("sendMessage","1");
startActivity(intent);
/*PendingIntent pi = PendingIntent.getService(Server.this, 0, myIntent, 0);
AlarmManager almmgr = (AlarmManager) getSystemService(ALARM_SERVICE);
Calendar cldr = Calendar.getInstance();
int min1 = cldr.get(Calendar.MINUTE);
cldr.setTimeInMillis(System.currentTimeMillis());
cldr.add(Calendar.SECOND, 30);
almmgr.set(AlarmManager.RTC_WAKEUP, cldr.getTimeInMillis(), pi);*/
}
但是它崩溃了?,该怎么办?