开发者

What does getRingerMode() return on an Android tablet?

I've got a bug report that sound doesn't work on an ASUS Transformer tablet running 3.0.

I don't do anything too weird, just use MediaPlayer and it seems to work on a wide range of phones. However, I use the method described in this post to disable sounds if getRingerMode() returns something other than RINGER_MODE_NORMAL. That way if the user has their phone on "vibrate only" they don't get surprising sound output (since media and ringer use separate volume controls).

Is it possible that on an Android tablet the 开发者_StackOverflow中文版getRingerMode() function returns RINGER_MODE_SILENT if the tablet doesn't have phone capabilities?

EDIT: Just a note that on the emulator without changing anything I get RINGER_MODE_NORMAL.

EDIT 2: In a final act of desperation, I removed the ringer mode check and re-published on the Market. The guy has just confirmed that sounds now work. It seems that getRingerMode() returns something other than RINGER_MODE_NORMAL on some tablets at least.


This is the code from GingerBread. It will return RINGER_MODE_NORMAL if IAudioService can't return getRingerMode();

/**
 * Returns the current ringtone mode.
 *
 * @return The current ringtone mode, one of {@link #RINGER_MODE_NORMAL},
 *         {@link #RINGER_MODE_SILENT}, or {@link #RINGER_MODE_VIBRATE}.
 * @see #setRingerMode(int)
 */
public int getRingerMode() {
    IAudioService service = getService();
    try {
        return service.getRingerMode();
    } catch (RemoteException e) {
        Log.e(TAG, "Dead object in getRingerMode", e);
        return RINGER_MODE_NORMAL;
    }
}

http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/2.3_r1/android/media/AudioManager.java/?v=source

One step below,

IAudioService#getRingerMode() throws android.os.RemoteException

The only difference in Honeycomb (reading the chengelog) in AudioManager is:

Added Fields int MODE_IN_COMMUNICATION

And nothing in 3.1 in this class, so I assume the Gingerbread code is still valid.

http://developer.android.com/sdk/api_diff/11/changes.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜