我的应用程序使用TTS(文本到语音)引擎,我遇到的冲突是Accessibility Talkback设置覆盖TTS试图说的任何内容.如果使用我的应用程序,我想禁用手机的对讲选项.
是否有某种权限来处理这个问题?我找不到任何东西.
我有一个普遍的问题。我想知道显示动画说话角色的标准方式?动画只是嘴巴在动。
我最初的想法是使用 GIF。Android 可以使用 android.graphics.Movie 类解码和显示动画 GIF。似乎运作良好,并控制资源。
但是其他人提到使用 AnimationSet,我可以在其中使用 addAnimation() 将动画添加到动画集,然后启动动画,这将一次加载所有动画。这似乎更难,但他提到这是制作动画的行业标准方式。
我只是想确认一下。什么是最好的方法?我知道的第三种选择是使用视频。但是如果我必须在视频和简单的 GIF 之间进行选择,我想我会选择 GIF,因为大小不同。
对此有任何意见吗?提前致谢。
来自parse.com的推送通知并不一致.随机推送通知将失败,导致GCM - MISMATCH SENDER ID"错误.我的理解是,通过编程,我们不必对GCM执行任何操作,因为parse.com将objectId发送到GCM.在任何一种情况下,我都没有能够找出有时出现此错误的任何具体原因,有时则不会.此外,我使用的是Parse版本,1.10.2.
我的Application类具有以下内容
Parse.initialize(this, APPLICATION_ID_DEBUG, CLIENT_KEY_DEBUG);
Parse.setLogLevel(Parse.LOG_LEVEL_VERBOSE);
ParsePush.subscribeInBackground(Constants.CHANNEL, new SaveCallback() {
@Override
public void done(ParseException e) {
if (Utils.checkIfNull(e)) {
// subscribed to channel
} else {
// failed to subscribe to channel
}
}
});
Run Code Online (Sandbox Code Playgroud)
用户登录我的应用程序后,我将一个频道附加到他们.我保存的频道数据只是我从服务器获取的用户唯一ID.
List<String> arryChannel = new ArrayList<>();
arryChannel.add(uniqueUserId);
final ParseInstallation parseInstallation = ParseInstallation.getCurrentInstallation();
parseInstallation.put(Constants.CHANNEL, arryChannel);
parseInstallation.saveInBackground(new SaveCallback() {
@Override
public void done(ParseException e) {
if (Utils.checkIfNull(e)) {
// update channel with user's unique id
} else {
// failed to update channel …Run Code Online (Sandbox Code Playgroud) 我使用该插件为 iOS 和 Android 应用程序安装 Crashlytics。我注意到的一个区别在于 Fabric 提供的门户。对于 iOS,有两种环境,一种是测试(绿色图标),另一种是生产(普通图标)。安卓不这样做。
我尝试通过在我的应用程序类中添加以下内容来创建两个不同的环境
Fabric.with(this, new Crashlytics());
if (Constants.DEBUG) {
Crashlytics.setString("version", "Production");
} else {
Crashlytics.setString("version", "Test");
}
Run Code Online (Sandbox Code Playgroud)
我认为这会创建两个不同的版本,但它没有做任何事情。如何为Android创建多个环境?提前致谢
我有一个帮助类来执行请求函数,我正在使用的一个方法如下.
private String buildQueryString(String url, List<NameValuePair> params) throws IOException {
StringBuilder sb = new StringBuilder();
if (params == null) return url;
for (NameValuePair param : params) {
sb.append(urlEncode(param.getName()));
sb.append("=");
sb.append(urlEncode(param.getValue()));
sb.append("&");
}
return url + "?" + sb.substring(0, sb.length() - 1);
}
Run Code Online (Sandbox Code Playgroud)
如果我将gradle更新为compileSdkVersion 23,则导入org.apache.http.NameValuePair不再存在.我很想知道更换的是什么?提前致谢!
EDIT -posting gradle-另外,我使用的是gradle-2.4
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
maven { url 'https://zendesk.artifactoryonline.com/zendesk/repo' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' …Run Code Online (Sandbox Code Playgroud) 我已经实现了ComponentCallbacks2,并且从未调用过onTrimMemory。我正在尝试使用Application类和自定义生命周期来管理内存。任何帮助,不胜感激。
public class MemoryManager implements ComponentCallbacks2 {
private static List<MemoryInfo> memInfoList = new ArrayList<>();
public interface MemoryInfo {
void releaseMemory();
}
public static void registerMemoryListener(MemoryInfo memoryInfo) {
memInfoList.add(memoryInfo);
}
public static void unregisterMemoryListener(MemoryInfo memoryInfo) {
memInfoList.remove(memoryInfo);
}
@Override
public void onTrimMemory(int level) {
Log.i("TEST", "onTrimMemory called"); // does not get called
switch (level) {
case ComponentCallbacks2.TRIM_MEMORY_RUNNING_LOW:
try {
for (int i = memInfoList.size() - 1; i >= 0; i--) {
try {
memInfoList.get(i).releaseMemory(); // is this correct implementation?
} catch …Run Code Online (Sandbox Code Playgroud) 如何使用Cognito for Android刷新访问令牌?文档建议如下(https://docs.aws.amazon.com/cognito/latest/developerguide/using-amazon-cognito-user-identity-pools-android-sdk.html):
// Implement authentication handler
AuthenticationHandler handler = new AuthenticationHandler {
@Override
public void onSuccess(CognitoUserSession userSession) {
// Authentication was successful, the "userSession" will have the current valid tokens
// Time to do awesome stuff
}
@Override
public void getAuthenticationDetails(final AuthenticationContinuation continuation, final String userID) {
// User authentication details, userId and password are required to continue.
// Use the "continuation" object to pass the user authentication details
// After the user authentication details are available, …Run Code Online (Sandbox Code Playgroud) 在Java中,我可以使用getClass(),然后从该类对象检索simpleName,而不会出现任何问题。
String tag = someObject.getClass().getSimpleName(); // java code
Run Code Online (Sandbox Code Playgroud)
但是当转换为Kotlin时,这会引起警告
调用使用在编译类路径中找不到的反射API。确保您在类路径中有kotlin-reflect.jar
Kotlin代码是
someObject::class.simpleName!! // kotlin code
Run Code Online (Sandbox Code Playgroud)
避免的正确方法是什么
kotlin.jvm.KotlinReflectionNotSupportedError吗?需要对kotlin-reflect.jar的附加依赖。也许最好使用:: class.java.simpleName
我需要帮助创建一个正则表达式来删除所有特殊字符,包括逗号,但不包括句点。我试图做的是转义所有我不想要的字符、符号和标点符号。它没有按预期工作。
replace("[-\\[\\]^/,'*:.!><~@#\$%+=?|\"\\\\()]+".toRegex(), "")
Run Code Online (Sandbox Code Playgroud)
我删除了句点并进行了测试。它不起作用。
replace("[-\\[\\]^/,'*:!><~@#\$%+=?|\"\\\\()]+".toRegex(), "")
Run Code Online (Sandbox Code Playgroud)
例如,让我们采用字符串“if {cat.is} in a hat, then I eat green Eggs and ham!”。
我想要结果
if {cat.is} in a hat then I eat green eggs and ham(逗号和感叹号已删除)
注意:我想保留括号,尽管可以省略括号。
有人有解决方案吗?
这是我第一次尝试实现 SQLite,我遇到了一个我无法解决的常见错误。错误是
03-12 15:37:20.432: E/SQLiteDatabase(1603): Error inserting Test=test string value Entry=entry string value _id=1
03-12 15:37:20.432: E/SQLiteDatabase(1603): android.database.sqlite.SQLiteConstraintException: PRIMARY KEY must be unique (code 19)
Run Code Online (Sandbox Code Playgroud)
我对可能发生的事情有很高的理解。错误是说我的主键——对我来说是 _id——对于每个条目应该是唯一的。但据我所知,我只是想添加一个元素,我相信我已经根据我遵循的教程进行了设置。请看看我有什么,让我知道我做错了什么。提前致谢!
首先,我尝试使用以下行保存条目。我将 id 设置为 1,然后尝试在其他列中保存一些测试值
DatabaseManager.saveEntry(MainActivity.this, "1", "entry string value", "test string value");
Run Code Online (Sandbox Code Playgroud)
数据库管理器
public class DatabaseManager {
public static void saveEntry(Context context, String id, String entry, String test) {
try {
ContentValues values = getContentValuesEntryTable(id, entry, test);
ContentResolver resolver = context.getContentResolver();
Cursor cursor = resolver.query(EntryTable.CONTENT_URI, null, null, null, null);
if (cursor != null …Run Code Online (Sandbox Code Playgroud) android ×10
java ×2
kotlin ×2
animated-gif ×1
animation ×1
apache ×1
crashlytics ×1
regex ×1
sqlite ×1
string ×1