Reputation: 89
I am trying to update and log the changed modes for the ringer into a textview. Thanks for the Help!
Here is my receiver Manifest: (no permissions required from what I found)
<receiver android:name="RingTypeMainActivity$RingTypeBroadcastReceiver" >
<intent-filter>
<action android:name="android.media.RINGER_MODE_CHANGED" >
</action>
</intent-filter>
</receiver>
I am using a Broadcastreceiver inside my Activity as such: When I run the app nothing gets appended to the textview
(txtResults).
public static class RingTypeBroadcastReceiver extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent) {
int num = intent.getIntExtra(AudioManager.EXTRA_RINGER_MODE, -1);
switch (num) {
case 0:
txtResults.append("Mode " + String.valueOf(num) + " - Normal audio mode: not ringing and no call established.");
break;
case 1:
txtResults.append("Mode " + String.valueOf(num) + " - Ringing audio mode. An incoming is being signaled.");
break;
case 2:
txtResults.append("Mode " + String.valueOf(num) + " - In call audio mode. A telephony call is established.");
break;
case 3:
txtResults.append("Mode " + String.valueOf(num) + " - In communication audio mode. An audio/video chat or VoIP call is established.");
break;
default:
break;
}
Upvotes: 0
Views: 1207
Reputation: 6717
Your receiver name is not declared properly in your manifest file.
Change this line of code
<receiver android:name="RingTypeMainActivity$RingTypeBroadcastReceiver" >
to this
<receiver android:name=".RingTypeMainActivity$RingTypeBroadcastReceiver" >
Adding a dot (.) before the receiver name is short for your package name.
Upvotes: 1