Hi,
As a simple test I'm trying to have a broadcastReceiver that will notify the user with a Toast message that an hardware button was clicked in android.
I've created a receiver tag in my manifest file with a name .TestReceiver that listens to Action_CALL_BUTTON to be informed when the user clicks on the green SEND button:
<receiver android:name=".TestReceiver" >
<intent-filter>
<action android:name="android.intent.action.ACTION_CALL_BUTTON" />
</intent-filter>
</receiver>
Next, I created the TestReceiver class that extends BroadcastReceiver and creates a Toast. When I click on the call button I don't see the Toast message but I tested it on an activity and it shows. What am I missing here?
package com.example.helloandroid;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;
public class TestReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
CharSequence text = "Hello toast!";
int duration = Toast.LENGTH_SHORT;
Toast toast = Toast.makeText(context, text, duration);
toast.show();
}
}
Thanks