What would the pitfalls be of blocking calls on Android by setting the ringer volume to mute, then having an app play the ringer?
It's well-known on Android discussion forums and SO that Android's API doesn't have a good way of blocking calls. You can have an event trigger when a call comes in, but by the time your app suppresses the call, it has already rang once or twice.
My idea is to have an app that sets your ringtone volume to mute, then when a call arrives, it would look up the appropriate ringtone for that call and play it if the caller is in your address book. Effect开发者_如何学编程ively, it would block unwanted rings, though not unwanted calls.
Being a relatively inexperienced Android developer, I'd like to know what problems this might cause. What would be the major pitfalls, possible causes of bugs, and problems with the user experience (besides seeing their phone on mute, when it really isn't)?
Also, any recommendations on how to best implement this idea?
- Your app hangs, and the user misses the call.
- The user has set the music volume to zero, so the user never hears a peep from your app and misses the call.
- Another app disables yours or a task killer kills your app, and the user misses the call.
- The user uninstalls your app, and misses a call since the ringer is muted.
- A malicious app starts calling your activity and pranking the user they got a call.
Other than that, i see nothing wrong with your approach...
Android phones already have the capability to send callers directly to voice mail, right? (Mine does, but I haven't seen that many other models, so I don't know if that's a feature of the phone or the OS.)
It seems to me that if you want to come as close as possible to preventing an unwanted call from disturbing the user, routing the call to voice mail would be less disruptive: the call's already going to voice mail if the user doesn't/can't answer it, and no other settings would need to be altered.
One other consequence of the approach you mention above is that your app could potentially play the ringtone past the point where the user could answer the call, and that could lead to frustration, especially given that it happens occasionally now with no custom apps involved.
精彩评论