How to pass data to BroadcastReceiver?

后端 未结 5 983
难免孤独
难免孤独 2020-12-08 21:43

What I am trying to do is that the numbers to which my application sends messages to, are passed to the BraodcastReceiver...but so far either I am getting null or BroadcastR

5条回答
  •  抹茶落季
    2020-12-08 22:16

    Your problem is actually very simple. It's enough that change onReceive() code just like it :

    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();
    
        Log.i("Receiver", "Broadcast received: " + action);
    
       if(action.equals("my.action.string")){
           String state = bundle.getString("phN");
    
       }
    }
    

提交回复
热议问题