我有一个Android游戏,我需要播放短音.SoundPool在双核手机上崩溃,Mediaplayer有200毫秒+延迟,OpenSL需要SDK 9+(我支持1.5).这就离开了AudioTrack.
这就是我尝试过的.我像这样创建AudioTrack对象.
protected AudioTrack createAudioTrack() {
final int trackSize = 17408;
return new AudioTrack(AudioManager.STREAM_MUSIC, 44100, AudioFormat.CHANNEL_CONFIGURATION_STEREO, AudioFormat.ENCODING_PCM_16BIT, trackSize, AudioTrack.MODE_STATIC);
}
Run Code Online (Sandbox Code Playgroud)
然后我在游戏声音(约8)中为每个创建一个runnable.
private static class SoundRunnable implements Runnable {
private final AudioTrack sound;
private final byte[] rawAudio;
public SoundRunnable(final AudioTrack sound, final byte[] rawAudio){
this.sound = sound;
this.rawAudio = rawAudio;
sound.write(rawAudio, 0, rawAudio.length);
}
@Override
public void run() {
playSound();
}
private synchronized void playSound() {
switch (sound.getPlayState()) …Run Code Online (Sandbox Code Playgroud) 我正在尝试按照此页面上的说明从和Android应用程序连接到Alexa语音服务。https://developer.amazon.com/public/solutions/alexa/alexa-voice-service/docs/authorizing-your-alexa-enabled-product-from-an-android-or-ios-mobile-app
Bundle options = new Bundle();
String scope_data = "{\"alexa:all\":{\"productID\":\"" + PRODUCT_ID +
"\", \"productInstanceAttributes\": {\"deviceSerialNumber\":\"" + PRODUCT_DSN + "\"}}}";
options.putString(AuthzConstants.BUNDLE_KEY.SCOPE_DATA.val, scope_data);
options.putBoolean(AuthzConstants.BUNDLE_KEY.GET_AUTH_CODE.val, true);
options.putString(AuthzConstants.BUNDLE_KEY.CODE_CHALLENGE.val, CODE_CHALLENGE);
options.putString(AuthzConstants.BUNDLE_KEY.CODE_CHALLENGE_METHOD.val, "S256");
mAuthManager.authorize(APP_SCOPES, options, new AuthorizeListener());
Run Code Online (Sandbox Code Playgroud)
首先,我不知道应该使用APP_SCOPES。我将其设置为:
protected static final String[] APP_SCOPE = new String[]{"profile", "postal_code"};
Run Code Online (Sandbox Code Playgroud)
但我从服务器收到错误
AuthError cat= INTERNAL type=ERROR_SERVER_REPSONSE - com.amazon.identity.auth.device.AuthError: Error=invalid_scope error_description=An unknown scope was requested
Run Code Online (Sandbox Code Playgroud) 当我的用户执行涉及拖动对象的某些操作时,我正在禁用Android导航抽屉.这是为了防止他们意外打开抽屉.问题是我被日志消息淹没了.这使得很难解决其他问题.
这就是我锁定抽屉的方式.
drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
Run Code Online (Sandbox Code Playgroud)
这是我得到的日志消息.
E/ViewDragHelper: Ignoring pointerId=0 because ACTION_DOWN was not received for this pointer before ACTION_MOVE. It likely happened because ViewDragHelper did not receive all the events in the event stream.
E/ViewDragHelper: Ignoring pointerId=0 because ACTION_DOWN was not received for this pointer before ACTION_MOVE. It likely happened because ViewDragHelper did not receive all the events in the event stream.
E/ViewDragHelper: Ignoring pointerId=0 because ACTION_DOWN was not received for this pointer before ACTION_MOVE. It likely happened because ViewDragHelper did not …Run Code Online (Sandbox Code Playgroud) 尝试从 Amazon Kindle Fire 设备上的 Google Firebase 访问实时数据库时出现以下错误。
Caused by: java.lang.RuntimeException: com.google.android.gms.internal.zzqi$zza: No acceptable module found. Local version is 0 and remote version is 0.
Run Code Online (Sandbox Code Playgroud)
我相信这是因为缺少 Google Play 服务。这是否意味着 Firebase 无法在 Kindle Fire 设备上运行?
他们俩名字里都有“火”,这不算什么!?
编辑:
我认为这可能与 Proguard 有关。我的日志文件中也出现此错误。
无法加载模块描述符类:在路径上找不到类“com.google.android.gms.dynamite.descriptors.com.google.android.gms.firebase_database.ModuleDescriptor”
我在以下代码中收到一个 RARE 空指针异常:
class Artist {
fun draw(canvas: Canvas, state: State){
state.drawableObjects.forEach {
it.draw(canvas) //NULL POINTER!?! Can not call draw(Canvas) on null object
}
}
}
class State {
var drawableObjects = listOf<DrawableObject>()
set(value) {
field = value.filter { it.isVisible } // Why not crash here if null?
}
}
class DrawableObject(val isVisible: Boolean) {
fun draw(canvas: Canvas) { }
}
Run Code Online (Sandbox Code Playgroud)
这怎么可能?列表 drawableObjects 是不可变的。它也不允许空对象。当列表更改时,会设置一个全新的列表以防止在绘制调用期间进行修改。
我绝对应该提到涉及多个线程。仅 2 个线程。一个调用 Artist.draw() 和第二个调用 State.drawableObjects = listOf()