Android LocalBroadcastManager工作不正常
我这里有点小问题,不知道怎么了。LocalBroadcastManager按其应有的方式工作,但在我在其中添加了一些代码(以便能够处理2个不同的广播)后,它停止了工作,我不知道为什么 这是一个工作正常的Android LocalBroadcastManager工作不正常,android,android-broadcast,Android,Android Broadcast,我这里有点小问题,不知道怎么了。LocalBroadcastManager按其应有的方式工作,但在我在其中添加了一些代码(以便能够处理2个不同的广播)后,它停止了工作,我不知道为什么 这是一个工作正常的 private BroadcastReceiver onNotice= new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) {
private BroadcastReceiver onNotice= new BroadcastReceiver()
{
@Override
public void onReceive(Context context, Intent intent)
{
String testeBroadcast = intent.getAction();
if (testeBroadcast.equals("Loadscreen"))
{
alertLoad.cancel();
}
fill_Main_TextV();
}
};
它是从这里寄来的
MainActivity testeActivity = new MainActivity();
public static final String intService = "Loadscreen";
public Loadscreen()
{
super(intService);
// TODO Auto-generated constructor stub
}
@Override
protected void onHandleIntent(Intent intent)
{
testeActivity.fill_tabcli();
Intent in = new Intent(intService);
LocalBroadcastManager.getInstance(this).sendBroadcast(in);
}
我在BroadcastReceiver上做的更改是:
private BroadcastReceiver onNotice= new BroadcastReceiver()
{
@Override
public void onReceive(Context context, Intent intent)
{
String testeBroadcast = intent.getAction();
if (testeBroadcast.equals("Loadscreen"))
{
alertLoad.cancel();
}
if (testeBroadcast.equals("Accoes"));
{
CliInfo cliente = GlobalVars.getClientes_Info().get(GlobalVars.get_selected_client()+"");
for (String idAccoes : nomeficheiros)
{
for(accoes_cli teste : cliente.getAccoes())
{
int cliIdAccoes = teste.getId_accao();
if (idAccoes.equals(cliIdAccoes+""))
{
cliente.getAccoes().remove(teste);
}
}
}
}
fill_Main_TextV();
}
};
第二个广播是:
public void escreve()
{
String esc_data = GlobalVars.year+"-"+GlobalVars.month+"-"+GlobalVars.day;
esc_data=GlobalFunctions.converte_data(esc_data);
try
{
writer = new FileWriter(GlobalVars.folder + "/" + esc_id + "_" + esc_data + ".acc");
writer.write(esc_accao + ";" + esc_resultado + ";" + esc_c1 + ";" + esc_c2 + ";" + esc_c3);
writer.flush();
writer.close();
}
catch (IOException e)
{
e.printStackTrace();
GlobalFunctions.toast_message(contexto, contexto.getString(R.string.accoes_salvo_erro));
}
finally
{
GlobalFunctions.toast_message(contexto, contexto.getString(R.string.accoes_salvo));
MainActivity.nomeficheiros.add(esc_id);
Intent in = new Intent(intService);
LocalBroadcastManager.getInstance(this).sendBroadcast(in);
}
}
我做错了什么?BoreadCastrecever总共只能处理1个吗