我希望从我的Android设备发送信息到微控制器(如Arduino).使用蓝牙经典我只需将一个字节数组数据发送到微控制器,并相应地处理字节数组.
我开始阅读有关蓝牙低功耗的内容,我听到所有关于GATT配置文件的讨论.我为什么要创建GATT档案?在将信息从Android设备交换到微控制器的情况下,GATT配置文件会为我做什么?
提前致谢!
android bluetooth bluetooth-lowenergy android-bluetooth gatt
我遇到以下情况时,最近一直在玩Bitmaps和调色板:
java.lang.IllegalArgumentException: background can not be translucent
at android.support.v7.graphics.ColorUtils.findMinimumAlpha(ColorUtils.java:90)
at android.support.v7.graphics.ColorUtils.getTextColorForBackground(ColorUtils.java:127)
at android.support.v7.graphics.Palette$Swatch.ensureTextColorsGenerated(Palette.java:621)
at android.support.v7.graphics.Palette$Swatch.getTitleTextColor(Palette.java:605)
Run Code Online (Sandbox Code Playgroud)
深入了解源代码,我发现:
private static int findMinimumAlpha(int foreground, int background, double minContrastRatio) {
if (Color.alpha(background) != 255) {
throw new IllegalArgumentException("background can not be translucent");
}
...
}
Run Code Online (Sandbox Code Playgroud)
我使用的图像是这样的:

我认为这个问题与图像在某种程度上完全透明有关.我目前正在执行与throw子句几乎相同的检查Color.alpha(palette.getSomeColor()) != 255,但这只是错误的.
在处理Palettes时是否有一种解决这个问题的方法?我觉得好像这是一个常见的错误,我必须做错了什么,或者错过了一些关于这个的指南.
当使用proguard改装时,我得到以下异常(注意,没有Proguard一切正常):
java.lang.ClassCastException: com.google.gson.internal.LinkedTreeMap cannot be cast to com.path.to.my.model
at com.path.to.my.callback.onResponse(Unknown Source)
at retrofit.ExecutorCallAdapterFactory$ExecutorCallback$1.run(Unknown Source)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5351)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:908)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:703)
Run Code Online (Sandbox Code Playgroud)
我的proguard文件如下:
-dontwarn okio.**
-dontwarn retrofit.**
-keep class retrofit.** { *; }
-keepattributes Signature
-keepattributes Exceptions
Run Code Online (Sandbox Code Playgroud)
与我正在使用的Retrofit相关的依赖项是:
compile 'com.squareup.retrofit:retrofit:2.0.0-beta1'
compile 'com.squareup.retrofit:converter-gson:2.0.0-beta1'
Run Code Online (Sandbox Code Playgroud)
为什么会这样?我怎样才能找到问题?故障排除方法非常有帮助.提前致谢!
我需要打开自定义Chrome标签,将用户带到我的网站,然后将用户重定向回应用.它类似于为OAuth启动页面.
这是Android方面的样子......
AndroidManifest.xml(将意图过滤器添加到用于侦听URI的活动)
<activity android:name=".app.MyActivity"
android:label="@string/title"
android:theme="@style/AppTheme"
android:launchMode="singleTask"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="mytest" />
</intent-filter>
</activity>
Run Code Online (Sandbox Code Playgroud)
Activity.java(启动自定义chrome选项卡)
private void goToSite() {
CustomTabsIntent.Builder intentBuilder = new CustomTabsIntent.Builder();
int toolbarColor = getResources().getColor(R.color.primary);
intentBuilder.setToolbarColor(toolbarColor);vice_key(), shared().getAccessToken());
intentBuilder.build().launchUrl(this, Uri.parse("https://example.com/some-page"));
}
Run Code Online (Sandbox Code Playgroud)
在我的服务器上,用户完成一个表单并最终被带到一个页面,该页面应该将它们重定向回应用程序...
server.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Redirecting...</title>
<script>
var redirectToApp = function() {
setTimeout(function appNotInstalled() {
window.location.replace("http://example.com/app-not-installed");
}, 100);
window.location.replace("mytest://justanexample");
};
window.onload = redirectToApp;
</script>
</head>
<body></body>
</html>
Run Code Online (Sandbox Code Playgroud)
但我没有被重定向到应用程序.我怀疑我的服务器代码有问题,因为类似的设置(清单和活动代码)在处理OAuth页面时有效.我的服务器代码有什么问题?我该如何解决这个问题?
编辑
Android端似乎是正确的 - …
在我的应用程序中,我有一个RelativeLayout包含另外两个RelativeLayouts.第一个RelativeLayout用于OpenGL视图.第二个用于放置Buttons和其他Views.我能够在OpenGL中处理好的触摸事件,除非它们发生在其中一个上Views.
这通常很好,但有时我希望OpenGL视图也接收事件,但前面的View总是消耗触摸事件.我试过使用以下,没有运气:
@Override
public boolean onInterceptTouchEvent(MotionEvent ev)
{
onTouchEvent(ev);
return false;
}
Run Code Online (Sandbox Code Playgroud) 是否在编译时在运行时或提前创建了匿名Java类?
根据Java文档,They are like local classes except that they do not have a name所以我的猜测是它们是提前创建的.如果你能引用你的消息来源或知道如何测试这样的东西,请告诉我!
我需要在C++中定义一个字符.现在我有:
#define ENQ (char)5
Run Code Online (Sandbox Code Playgroud)
有没有办法定义一个类似于如何使用l后缀定义long的字符(例如5l)?
可能是一个非常基本的问题,但无论如何我都会问.我尝试使用Google搜索我的问题,但由于我不知道要搜索的关键字,因此无法获得结果.任何更多信息的链接将不胜感激.
那么,执行后语句的值会发生什么变化?也许只是因为我在IRB,我自己很困惑.例如,如果我在IRB(交互式Ruby)中并执行以下操作:"Hello World"
价值是否会消失,永远消失?或者它是否临时存储在可以访问的地方?提前致谢!
我需要将函数引用存储为char*,然后仅使用char*调用该函数.
我正在寻找类似的东西:
char* funcRef = (char*)myFunc;
//...
(void (*funcRef)())();
Run Code Online (Sandbox Code Playgroud)
你怎么做到这一点?(注意:我不是要求如何通过引用调用函数,只要它可以将对它的引用存储为char*然后将其转换回来)