想了解在游戏中,如果我从窗口小部件运行,图像会在Android设备上消失,但在第一次安装APK时不会消失的新动态吗?本文将为您提供详细的信息,此外,我们还将为您介绍关于ajax在某些Android设备
想了解在游戏中,如果我从窗口小部件运行,图像会在Android设备上消失,但在第一次安装APK时不会消失的新动态吗?本文将为您提供详细的信息,此外,我们还将为您介绍关于ajax在某些Android设备上运行,而不是在其他设备上运行、Android adb安装apk时提示Invalid APK file的问题、Android Beacon Library在一台Android 4.4设备上运行良好,但在另一台Android设备上运行良好、android – ActionBar边框在叠加时不会消失的新知识。
本文目录一览:- 在游戏中,如果我从窗口小部件运行,图像会在Android设备上消失,但在第一次安装APK时不会消失
- ajax在某些Android设备上运行,而不是在其他设备上运行
- Android adb安装apk时提示Invalid APK file的问题
- Android Beacon Library在一台Android 4.4设备上运行良好,但在另一台Android设备上运行良好
- android – ActionBar边框在叠加时不会消失
在游戏中,如果我从窗口小部件运行,图像会在Android设备上消失,但在第一次安装APK时不会消失
我使用LibGDX创建了一个游戏,该游戏在我的计算机上运行良好.
我通过Gradle View->在Android Studio中创建了一个调试.apk.建立和然后复制我的android-debug.apk& android-debug-unaligned.apk到我的Android设备的下载文件夹.
现在,当我在Android设备上单击我的文件之一时,该设备会询问我是否要安装该设备并选择“是”,随后我打开游戏,即可正常运行.
现在,当我玩完游戏并尝试从小部件重新启动游戏时,就出现了问题.安装后,该小部件将安装在我的android-“桌面”(包含所有可以单击的应用程序的主屏幕)上.
如果我从小部件启动它,我的图形就会混乱并丢失&我不知道为什么?
初始屏幕缺少徽标图像.切换到MenuScreen时,图像丢失.当我切换到游戏屏幕时,图形完全混乱了.
当我重新安装游戏并再次运行它时,没有问题.
如果有人可以帮忙?
解决方法:
用例的不同之处在于运行应用程序的JVM的状态.在某些情况下,JVM是全新的,并且一切正常.但是,如果JVM被回收(因为Android并没有杀死它,只是将它放在后台),就会遇到问题.问题的核心很可能是您在重新启动应用程序时引用了前一次运行的OpenGL状态(例如,第一次运行的OpenGL纹理ID将在以后的运行中使用).由于OpenGL是有状态驱动程序,并且在失去上下文时会擦除应用程序的状态,因此您需要重新加载全局OpenGL状态.
有关潜在问题的描述,请参见Android static object lifecycle;有关诊断和处理该问题的某些Libgdx特定的技巧,请参见http://bitiotic.com/blog/2013/05/23/libgdx-and-android-application-lifecycle/.
ajax在某些Android设备上运行,而不是在其他设备上运行
这个问题至少浪费了2天.我有几个网页打包为Android应用程序.并且可以在浏览器和我的Android设备上完美运行,包括galaxy Tab 2.但不适用于Nexus.我没有它,所以我一直在测试APK和朋友.错误发生在AJAX.相同的代码对我有用,不适合他(还有其他人,我不知道他们的设备).
以下是我使用的小测试.如你所见,它没有错误(这是我的猜测).为什么不在所有Android设备上运行?我提到我已经使用Eclipse和Build.PhoneGap.com编译了这段代码(其他提到的文件在这里http://jumpshare.com/b/57O6tH).然而,同样的结果是:我得到的APK是在某些设备上工作,而不是在其他设备上.使用* file:///android_asset/www/import.html*对我没有帮助.错误是404,因为文件不存在.但它是!
哪里出错了?它让我疯狂 :).为什么这个代码在浏览器和我的galaxy Tab 2(和三星Gio)上的APK工作正常,但在Nexus(和其他设备)上没有?
<!DOCTYPE html> <html> <head> <Meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Test</title> <Meta name="viewport" content="width=device-width,initial-scale=1"> <link href="jquery.mobile-1.2.0.min.css" rel="stylesheet"/> <script src="jquery-1.8.3.min.js" type='text/javascript'></script> <script src="jquery.mobile-1.2.0.min.js" type='text/javascript'></script> <script type='text/javascript'> //$(document).ready(function() { $(document).bind("pageinit",function(){ $("#buton").bind('click',function(){ $.mobile.showPageLoadingMsg(); $.ajax({ url:'import.html',datatype:'html',type: 'GET',success:function(html){ $.mobile.hidePageLoadingMsg(); $("#result").html(html); },error: function(jqXHR,textStatus,errorThrown) { $("#result").html("ERRORS:"+errorThrown+"<hr>"+textStatus+"<hr>"+JSON.stringify(jqXHR)) $.mobile.hidePageLoadingMsg(); alert('Not working!!!'); } }) }); }); </script> </head> <body> <!-- Pagina de start --> <div data-role="page" id="start"> <div data-role="header" data-theme="b"> <h1>Test</h1> </div> <div data-role="content"> <button id="buton">AJAX!</button> <div id="result"></div> </div> </div> </body> </html>
由于它不能在16以下的API上运行,因此解决方案需要更多的行,以确保这种不存在的方法不会在以前的API中导致错误.
public class MainActivity extends Activity { /** Called when the activity is first created. */ WebView webView; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); webView = (WebView) findViewById(R.id.webView); webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY); webView.getSettings().setJavaScriptEnabled(true); int currentapiVersion = android.os.Build.VERSION.SDK_INT; if (currentapiVersion >= android.os.Build.VERSION_CODES.JELLY_BEAN){ fixNewAndroid(webView); } webView.setWebChromeClient(new WebChromeClient()); webView.loadUrl("file:///android_asset/www/index.html"); } @TargetApi(16) protected void fixNewAndroid(WebView webView) { try { webView.getSettings().setAllowUniversalAccessFromFileURLs(true); } catch(NullPointerException e) { } }
}
Android adb安装apk时提示Invalid APK file的问题
今天在使用adb命令安装apk时,无法安装成功,进入到android sdk 下的platform_tools下也是无法安装成功:
先贴一下我的调用过程
xu:~ xiaokai$ adb devices List of devices attached 0123456789ABCDEF device xu:~ xiaokai$ adb shell shell@T36DH_CM3:/ $ pm install /Users/xiaokai/Downloads/app-release.apk pkg: /Users/xiaokai/Downloads/app-release.apk Failure [INSTALL_FAILED_INVALID_URI] 1|shell@T36DH_CM3:/ $ adb install /Users/xiaokai/Downloads/app-release.apk Invalid APK file: /Users/xiaokai/Downloads/app-release.apk 255|shell@T36DH_CM3:/ $ exit xu:~ xiaokai$ adb install /Users/xiaokai/Downloads/app-release.apk [100%] /data/local/tmp/app-release.apk pkg: /data/local/tmp/app-release.apk Success
adb devices
首先调用了adb devices,查看有没有可用的手机,`0123456789ABCDEF device`说明有可用的手机,
adb shell
然后进入手机,安装apk,
pm install /Users/xiaokai/Downloads/app-release.apk
发现出现问题,
exit
退出前手机 ,进入root目录
adb install /Users/xiaokai/Downloads/app-release.apk
进行安装,发现安装成功,网上查了一下,下面这篇文章介绍了一些这方面的问题
补充上面文章:adb安装apk报错Failure [INSTALL_FAILED_INVALID_URI]
今天在使用adb命令安装一个apk时,遇到一个问题,记录如下:
1、下载了一个demo.apk,放在D:\A_Download目录下。
2、手机连上电脑,开启USB调试权限。然后在电脑端启动cmd,输入以下命令:
C:\Users\leon>adb devices List of devices attached 0123456789ABCDEF device
可以看出,手机已经成功连上。
3、输入adb shell命令,进入shell模式。然后使用install命令安装上述apk文件。但是提示失败:
C:\Users\leon>adb shell shell@android:/ $ install D:\A_Download\demo.apk BusyBox v1.20.2-jb bionic (2012-11-25 17:47 +0100) multi-call binary. Usage: install [-cdDsp] [-o USER] [-g GRP] [-m MODE] [SOURCE]... DEST Copy files and set attributes -c Just copy (default) -d Create directories -D Create leading target directories -s Strip symbol table -p Preserve date -o USER Set ownership -g GRP Set group ownership -m MODE Set permissions
分析了一下,原来是忘记使用pm前缀(关于install命令要加pm前缀的分析,请参见另一篇文章:安卓adb命令中pm工具的作用及用法详解)。于是修改命令:
shell@android:/ $ pm install D:\A_Download\demo.apk pkg: D:A_Downloaddemo.apk Failure [INSTALL_FAILED_INVALID_URI]
仍然提示失败!
经过反复的分析,我认为应该是因为adb命令下,无法识别windows目录信息导致。也就是说,adb命令无法识别此处的“D:\A_Download\demo.apk”目录。也正是因为这样,所以它给出的失败原因是INVALID_URI。
为了解决这个问题,其实办法很简单,只要退出adb shell的环境就好。于是输入exit命令回退到windows的cmd环境下,然后使用adb install命令,果然就成功了。
shell@android:/ $ exit C:\Users\leon>adb install D:\A_Download\demo.apk [100%] /data/local/tmp/demo.apk pkg: /data/local/tmp/demo.apk Success
当然,上述思路只是我自己想当然的,必须验证一下是否真是这么回事。怎么验证呢?
如上所述,根据我的猜测,上述安装方式之所以会失败,是因为adb环境无法识别windows系统的目录格式。所以,如果我们提前把文件拷贝到手机中,然后再进入adb shell环境并install,免去shell环境识别windows目录格式的步骤,应该就能成功。
于是,我直接在cmd环境下把apk文件push到手机中,然后进入adb shell环境,运行pm install命令,果然成功了!
C:\Users\leon>adb push D:\A_Download\demo.apk sdcard/demo.apk [100%] sdcard/demo.apk C:\Users\leon>adb shell shell@android:/ $ cd sdcard/ shell@android:/sdcard $ pm install demo.apk pkg: demo.apk Success
所以,总之一句话,adb shell环境下,系统无法识别windows的目录格式,要么就退回到cmd环境下,要么就提前把windows的文件拷贝到手机中。类似的问题就不会再出现了!
搞定,收工!
以上这篇Android adb安装apk时提示Invalid APK file的问题就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。
- adb通过wifi连接android设备流程解析
- Android adb命令中pm工具的作用及用法说明
- python中adb有什么功能
- Android user版通过adb_enable开启adb 调试 不提示对话框的流程分析
- 详解adb shell 常用命令
- Android PC端用ADB抓取指定应用日志实现步骤
- python+adb命令实现自动刷视频脚本案例
- 详解android adb常见用法
Android Beacon Library在一台Android 4.4设备上运行良好,但在另一台Android设备上运行良好
有关非工作设备的详细信息.
智能手表(通用)列为蓝牙4.0功能
MTK6572芯片组
型号EC720(似乎有很多变种)
Android 4.4.2
内核:3.4.67 chendalin-Z87-HD3#1 2014年12月27日
内部版本号:H82D.SMARTWATCH.OC4.0.20141447
自定义版本:1419655453
我正在使用相同的Radius Networks标签信标测试相同的应用程序.在这个测试中,我在我的设备的近距离内有相同的4个信标.
设备1是Nexus 7(2013),我还没有更新到Android L,它运行4.4.4
Device 2是一款通用的智能手表,在MTK6572上运行android 4.4.2.规格列出有蓝牙4.0
当我使用Android Beacon Library运行我的测试应用程序时,Nexus报告信标,但智能手表没有.它似乎检测到它们,但我看到logcat中的条目如:D / BluetoothAdapter:onScanResult() – Device = E5:E0:20:CF:63:32 RSSI = -60.当BeaconParser未设置为读取正确类型的信标时,通常会显示这些消息,但在我的情况下,我很确定这不是问题,因为nexus看到的信标具有完全相同的代码.
对于2个设备看起来非常不同的日志输出,我开始怀疑手表的android构建是否因为BLE支持被禁用或者具有不完整的堆栈.我已经仔细检查了蓝牙是否打开,并且还想注意该手表具有应用程序权限管理,我为应用程序请求的所有权限设置为“始终允许”.
这里来自smartwatch的部分logcat:
02-03 19:40:40.393 2620-2620/com.mapcushion.android.mapcushionpingl D/BeaconManager﹕ This consumer is not bound. binding: com.mapcushion.android.mapcushionpingl.Scan@41c7d2c0 02-03 19:40:40.435 2620-2620/com.mapcushion.android.mapcushionpingl D/BeaconManager﹕ consumer count is Now:1 ... 02-03 19:40:40.617 2620-2620/com.mapcushion.android.mapcushionpingl I/BeaconService﹕ beaconService version 2.1 is starting up 02-03 19:40:40.638 2620-2620/com.mapcushion.android.mapcushionpingl I/CycledLeScanner﹕ This is not Android 5.0. We are using old scanning APIs 02-03 19:40:40.645 2620-2620/com.mapcushion.android.mapcushionpingl D/ModelSpecificdistanceCalculator﹕ Finding best distance calculator for 4.4.2,KOT49H,EC720,alps 02-03 19:40:40.645 2620-2620/com.mapcushion.android.mapcushionpingl D/AndroidModel﹕ score is 0 for LGE;Nexus 4;KOT49H;4.4.2 compared to alps;EC720;KOT49H;4.4.2 02-03 19:40:40.645 2620-2620/com.mapcushion.android.mapcushionpingl D/AndroidModel﹕ score is 0 for LGE;Nexus 5;LPV79;4.4.2 compared to alps;EC720;KOT49H;4.4.2 02-03 19:40:40.645 2620-2620/com.mapcushion.android.mapcushionpingl W/ModelSpecificdistanceCalculator﹕ Cannot find match for this device. Using default 02-03 19:40:40.645 2620-2620/com.mapcushion.android.mapcushionpingl D/ModelSpecificdistanceCalculator﹕ Finding best distance calculator for 4.4.2,alps 02-03 19:40:40.645 2620-2620/com.mapcushion.android.mapcushionpingl D/AndroidModel﹕ score is 0 for LGE;Nexus 4;KOT49H;4.4.2 compared to alps;EC720;KOT49H;4.4.2 02-03 19:40:40.646 2620-2620/com.mapcushion.android.mapcushionpingl D/AndroidModel﹕ score is 0 for LGE;Nexus 5;LPV79;4.4.2 compared to alps;EC720;KOT49H;4.4.2 02-03 19:40:40.646 2620-2620/com.mapcushion.android.mapcushionpingl W/ModelSpecificdistanceCalculator﹕ Cannot find match for this device. Using default 02-03 19:40:40.648 2620-2620/com.mapcushion.android.mapcushionpingl D/BeaconService﹕ No org.altbeacon.beacon.SimulatedScanData class exists. 02-03 19:40:40.649 2620-2620/com.mapcushion.android.mapcushionpingl D/ActivityThread﹕ SVC-CREATE_SERVICE handled : 0 / CreateServiceData{token=android.os.BinderProxy@41cbbec8 className=org.altbeacon.beacon.service.BeaconService packageName=com.mapcushion.android.mapcushionpingl intent=null} 02-03 19:40:40.650 2620-2620/com.mapcushion.android.mapcushionpingl I/BeaconService﹕ binding 02-03 19:40:40.656 2620-2620/com.mapcushion.android.mapcushionpingl D/ActivityThread﹕ SVC-BIND_SERVICE handled : 0 / BindServiceData{token=android.os.BinderProxy@41cbbec8 intent=Intent { cmp=com.mapcushion.android.mapcushionpingl/org.altbeacon.beacon.service.BeaconService }} 02-03 19:40:40.723 2620-2620/com.mapcushion.android.mapcushionpingl D/GraphicBuffer﹕ create handle(0x552ed2b8) (w:256,h:240,f:1) 02-03 19:40:40.725 2620-2620/com.mapcushion.android.mapcushionpingl I/MaliEGL﹕ [Mali]surface->num_buffers=4,surface->num_frames=3,win_min_undequeued=1 02-03 19:40:40.725 2620-2620/com.mapcushion.android.mapcushionpingl I/MaliEGL﹕ [Mali]max_allowed_dequeued_buffers=3 02-03 19:40:40.725 2620-2620/com.mapcushion.android.mapcushionpingl D/GraphicBuffer﹕ close handle(0x552ed2b8) (w:256 h:240 f:1) 02-03 19:40:40.733 2620-2620/com.mapcushion.android.mapcushionpingl D/GraphicBuffer﹕ create handle(0x553ec108) (w:256,f:1) 02-03 19:40:40.735 2620-2620/com.mapcushion.android.mapcushionpingl D/Openglrenderer﹕ Enabling debug mode 0 02-03 19:40:40.737 2620-2620/com.mapcushion.android.mapcushionpingl D/GraphicBuffer﹕ create handle(0x5542c8a8) (w:768,h:768,f:1) 02-03 19:40:40.741 2620-2620/com.mapcushion.android.mapcushionpingl W/MALI﹕ MTK_AUX_isMTKFormat:168: int MTK_AUX_isMTKFormat(ANativeWindowBuffer_t*): format=1 02-03 19:40:40.743 2620-2620/com.mapcushion.android.mapcushionpingl D/Openglrenderer﹕ setViewport 240x240 <0x553ec690> 02-03 19:40:40.745 2620-2620/com.mapcushion.android.mapcushionpingl D/BeaconManager﹕ we have a connection to the service Now 02-03 19:40:40.747 2620-2620/com.mapcushion.android.mapcushionpingl D/BeaconManager﹕ callback packageName: com.mapcushion.android.mapcushionpingl 02-03 19:40:40.747 2620-2620/com.mapcushion.android.mapcushionpingl D/BeaconManager﹕ This consumer is already bound ... 02-03 19:40:40.814 2620-2620/com.mapcushion.android.mapcushionpingl I/BeaconService﹕ start ranging received 02-03 19:40:40.814 2620-2620/com.mapcushion.android.mapcushionpingl D/BeaconService﹕ Currently ranging 1 regions. 02-03 19:40:40.814 2620-2620/com.mapcushion.android.mapcushionpingl D/CycledLeScanner﹕ start called 02-03 19:40:40.828 2620-2620/com.mapcushion.android.mapcushionpingl D/CycledLeScanner﹕ starting a new scan cycle 02-03 19:40:40.829 2620-2620/com.mapcushion.android.mapcushionpingl D/BluetoothAdapter﹕ isEnabled 02-03 19:40:40.834 2620-2620/com.mapcushion.android.mapcushionpingl D/CycledLeScanner﹕ starting a new bluetooth le scan 02-03 19:40:40.835 2620-2620/com.mapcushion.android.mapcushionpingl D/BluetoothAdapter﹕ startLeScan(): null 02-03 19:40:40.874 2620-2633/com.mapcushion.android.mapcushionpingl D/BluetoothAdapter﹕ onClientRegistered() - status=0 clientIf=1 02-03 19:40:40.879 2620-2620/com.mapcushion.android.mapcushionpingl D/CycledLeScanner﹕ Waiting to stop scan cycle for another 1100 milliseconds 02-03 19:40:40.880 2620-2620/com.mapcushion.android.mapcushionpingl D/CycledLeScanner﹕ Scan started 02-03 19:40:40.880 2620-2620/com.mapcushion.android.mapcushionpingl D/CycledLeScanner﹕ Set scan periods called with 1100,0 Background mode must have changed. 02-03 19:40:40.881 2620-2620/com.mapcushion.android.mapcushionpingl D/CycledLeScanner﹕ We are not in the background. Cancelling wakeup alarm 02-03 19:40:40.881 2620-2620/com.mapcushion.android.mapcushionpingl D/CycledLeScanner﹕ cancel wakeup alarm: null 02-03 19:40:41.084 2620-2634/com.mapcushion.android.mapcushionpingl D/BluetoothAdapter﹕ onScanResult() - Device=E5:E0:20:CF:63:32 RSSI=-45 02-03 19:40:41.084 2620-2634/com.mapcushion.android.mapcushionpingl D/CycledLeScannerForJellyBeanMr2﹕ got record
这是我的代码:
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_scan); mHandler = new android.os.Handler(); beaconManager = BeaconManager.getInstanceForApplication(this); beaconManager.setDebug(true); beaconManager.getBeaconParsers().add(new BeaconParser(). setBeaconLayout(" m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24")); beaconManager.bind(this); sendbeacons(); } @Override public void onBeaconServiceConnect() { beaconManager.setRangeNotifier(new RangeNotifier() { @Override public void didRangeBeaconsInRegion(Collection<Beacon> beacons,Region region) { System.out.println("------- didRangeBeacons!!!!"); iBeacons = beacons; System.out.println("------ num:: " + iBeacons.size()); /* for(Beacon iBeacon : iBeacons) { Log.i("Beacon","found \nProxUUID: " + iBeacon.getId1() + "\ntx: " + Integer.toString(iBeacon.getTxPower()) + "\nmanu: " + Integer.toString(iBeacon.getManufacturer()) + "\ndistance: " + Double.toString(iBeacon.getdistance()) + "\nRSSI:" + Integer.toString(iBeacon.getRSSi()) + "\nTxPow:" + Integer.toString(iBeacon.getTxPower()) + "\nBeacon type code:" + Double.toString(iBeacon.getBeaconTypeCode()) + "\n------------------------------------------------"); } */ } }); try { beaconManager.startRangingBeaconsInRegion(new Region("briansbeacons",null,null)); } catch(remoteexception e) { e.printstacktrace(); } beaconManager.bind(this); }
编辑1:
添加更多特定日志条目以尝试显示信标检测中的差异:我删除了除一个信标之外的所有信息,我注意到工作设备正在通过UUID识别信标,而非工作设备则不是.但我在工作设备的日志中找不到对Device = E5:E0:20:CF:63:32的任何引用.
Nexus 7(工作):
02-02 23:48:14.795 10727-10751/com.mapcushion.android.mapcushionpingl D/BeaconService﹕ beacon detected multiple times in scan cycle :id1: 2f234454-cf6d-4a0f-adf2-f4911ba9ffa6 id2: 4 id3: 101 02-02 23:48:14.795 10727-10751/com.mapcushion.android.mapcushionpingl D/BeaconService﹕ beacon detected :id1: 2f234454-cf6d-4a0f-adf2-f4911ba9ffa6 id2: 4 id3: 101 02-02 23:48:14.795 10727-10751/com.mapcushion.android.mapcushionpingl D/BeaconService﹕ looking for ranging region matches for this beacon 02-02 23:48:14.795 10727-10751/com.mapcushion.android.mapcushionpingl D/BeaconService﹕ matches ranging region: id1: null id2: null id3: null 02-02 23:48:14.795 10727-10751/com.mapcushion.android.mapcushionpingl D/RangeState﹕ adding id1: 2f234454-cf6d-4a0f-adf2-f4911ba9ffa6 id2: 4 id3: 101 to existing range for: org.altbeacon.beacon.service.RangedBeacon@41eb5380 02-02 23:48:14.915 10727-10738/com.mapcushion.android.mapcushionpingl D/CycledLeScannerForJellyBeanMr2﹕ got record 02-02 23:48:14.915 10727-10759/com.mapcushion.android.mapcushionpingl D/BeaconParser﹕ This is not a matching Beacon advertisement. (Was expecting be ac. The bytes I see are: 02011a0bff4c0009060102c0a801130000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 02-02 23:48:14.915 10727-10759/com.mapcushion.android.mapcushionpingl D/BeaconParser﹕ This is not a matching Beacon advertisement. (Was expecting 02 15. The bytes I see are: 02011a0bff4c0009060102c0a801130000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
SmartWatch(不工作):
02-02 23:46:52.598 3351-3364/com.mapcushion.android.mapcushionpingl D/BluetoothAdapter﹕ onScanResult() - Device=E5:E0:20:CF:63:32 RSSI=-31 02-02 23:46:52.599 3351-3364/com.mapcushion.android.mapcushionpingl D/CycledLeScannerForJellyBeanMr2﹕ got record 02-02 23:46:52.600 3351-3364/com.mapcushion.android.mapcushionpingl D/BluetoothDevice﹕ mAddress: E5:E0:20:CF:63:32 02-02 23:46:52.603 3351-3383/com.mapcushion.android.mapcushionpingl D/BeaconParser﹕ This is not a matching Beacon advertisement. (Was expecting be ac. The bytes I see are: 0201000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 02-02 23:46:52.603 3351-3383/com.mapcushion.android.mapcushionpingl D/BeaconParser﹕ This is not a matching Beacon advertisement. (Was expecting 02 15. The bytes I see are: 0201000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 02-02 23:46:52.605 3351-3383/com.mapcushion.android.mapcushionpingl D/BeaconParser﹕ This is not a matching Beacon advertisement. (Was expecting 02 15. The bytes I see are: 0201000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 02-02 23:46:53.432 3351-3351/com.mapcushion.android.mapcushionpingl D/CycledLeScanner﹕ Waiting to stop scan cycle for another 98 milliseconds 02-02 23:46:53.531 3351-3351/com.mapcushion.android.mapcushionpingl D/CycledLeScanner﹕ Done with scan cycle 02-02 23:46:53.531 3351-3351/com.mapcushion.android.mapcushionpingl D/BeaconService﹕ Calling ranging callback
我注意到的另一件事是,在非工作设备中,对BeaconService的唯一引用如下:
02-02 23:46:52.364 3351-3351/com.mapcushion.android.mapcushionpingl D/BeaconService﹕ Calling ranging callback 02-02 23:46:52.364 3351-3351/com.mapcushion.android.mapcushionpingl D/Callback﹕ attempting callback via intent: ComponentInfo{com.mapcushion.android.mapcushionpingl/org.altbeacon.beacon.BeaconIntentProcessor}
而在工作设备中,大多数信标的记录似乎来自该类…
编辑 – 更新2:
回答David关于MAC地址的问题
以下代码:
beaconManager.setRangeNotifier(new RangeNotifier() { @Override public void didRangeBeaconsInRegion(Collection<Beacon> beacons,Region region) { System.out.println("------- didRangeBeacons!!!!"); iBeacons = beacons; System.out.println("------ num:: " + iBeacons.size()); for(Beacon iBeacon : iBeacons) { Log.i("Beacon","\n------------------------------------------------"); Log.d(TAG,"Mac address is: "+iBeacon.getBluetoothAddress()); Log.i("Beacon","\n------------------------------------------------"); } } });
在工作Nexus 7上产生:
02-03 19:44:57.200 3192-3438/com.mapcushion.android.mapcushionpingl I/System.out﹕ ------- didRangeBeacons!!!! 02-03 19:44:57.200 3192-3438/com.mapcushion.android.mapcushionpingl I/System.out﹕ ------ num:: 1 02-03 19:44:57.200 3192-3438/com.mapcushion.android.mapcushionpingl I/Beacon﹕ ------------------------------------------------ 02-03 19:44:57.200 3192-3438/com.mapcushion.android.mapcushionpingl D/RangingActivity﹕ Mac address is: E5:E0:20:CF:63:32 02-03 19:44:57.200 3192-3438/com.mapcushion.android.mapcushionpingl I/Beacon﹕ ------------------------------------------------
在智能手表上:
02-03 19:40:46.671 2620-2671/com.mapcushion.android.mapcushionpingl I/System.out﹕ ------- didRangeBeacons!!!! 02-03 19:40:46.671 2620-2671/com.mapcushion.android.mapcushionpingl I/System.out﹕ ------ num:: 0
因此BeaconManager(或底层的android API)没有将“设备”视为信标,但它确实用这条线识别具有相同MAC地址的信标:
02-03 19:40:46.486 2620-2633/com.mapcushion.android.mapcushionpingl D/BluetoothDevice﹕ mAddress: E5:E0:20:CF:63:32
编辑3:
我决定退后一步,尝试使用Android蓝牙API直接查询信标.
基本上我只是想输出返回的字节,看看为什么没有识别信标.并且对于相同的信标,输出看起来完全不同,只有前两个字节具有智能手表所见的信标数据,而nexus 7具有30个字节的数据.
到目前为止,我尝试更改SCAN_TIME没有任何效果.手表收到的数据是否有迹象表明它无法读取数据包?
我使用了以下代码:
private static final long SCAN_TIME = 5000; boolean mScanning = false; private void scanLeDevice(final boolean enable) { Log.i(null,"Inside scanLeDevice"); Log.i(null,"scan time is: " + SCAN_TIME); if (enable) { // Stops scanning after a pre-defined scan period. mHandler.postDelayed(new Runnable() { @Override public void run() { mScanning = false; Log.i(null,"Calling stopLeScan"); mBluetoothAdapter.stopLeScan(mLeScanCallback); } },SCAN_TIME); mScanning = true; Log.i(null,"Calling startLeScan"); mBluetoothAdapter.startLeScan(mLeScanCallback); } else { mScanning = false; mBluetoothAdapter.stopLeScan(mLeScanCallback); } } private BluetoothAdapter.LeScanCallback mLeScanCallback = new BluetoothAdapter.LeScanCallback() { @Override public void onLeScan(final BluetoothDevice device,int RSSi,final byte[] scanRecord) { runOnUiThread(new Runnable() { @Override public void run() { Log.i(null,"INSIDE ONLESCAN"); //DO MY WORK Log.i(null,"scanned record: " + scanRecord.length); int startByte = 2; boolean patternFound = false; for(int i=0; i<scanRecord.length; i++) { Log.i(null,"byte " + i + ": " + scanRecord[i]); } while (startByte <= 5) { Log.i(null,"scanned record: " + scanRecord.length); Log.i(null,"Identifier check: " + ((int) scanRecord[startByte + 2] & 0xff) + " == " + 0x02); Log.i(null,"Length of data : " + ((int) scanRecord[startByte + 3] & 0xff) + "==" + (0x15)); //Log.i(null," iBeacon Identifier: " + (scanRecord[startByte + 2] & 0xff)); if (((int) scanRecord[startByte + 2] & 0xff) == 0x02 && //Identifies an iBeacon ((int) scanRecord[startByte + 3] & 0xff) == 0x15) { //Identifies correct data length patternFound = true; break; } startByte++; } if (patternFound) { //Convert to hex String byte[] uuidBytes = new byte[16]; System.arraycopy(scanRecord,startByte+4,uuidBytes,16); String hexString = bytesToHex(uuidBytes); //Here is your UUID String uuid = hexString.substring(0,8) + "-" + hexString.substring(8,12) + "-" + hexString.substring(12,16) + "-" + hexString.substring(16,20) + "-" + hexString.substring(20,32); //Here is your Major value int major = (scanRecord[startByte+20] & 0xff) * 0x100 + (scanRecord[startByte+21] & 0xff); //Here is your Minor value int minor = (scanRecord[startByte+22] & 0xff) * 0x100 + (scanRecord[startByte+23] & 0xff); System.out.println("-------------output------ : " + uuid + " maj: " + major + " min: " + minor ); } } }); } }; }
这是输出:
nexus 7(工作):
02-03 22:50:43.811 7303-7303/com.mapcushion.android.mapcushionpingl I/﹕ INSIDE ONLESCAN 02-03 22:50:43.811 7303-7303/com.mapcushion.android.mapcushionpingl I/﹕ scanned record: 62 02-03 22:50:43.811 7303-7303/com.mapcushion.android.mapcushionpingl I/﹕ byte 0: 2 02-03 22:50:43.811 7303-7303/com.mapcushion.android.mapcushionpingl I/﹕ byte 1: 1 02-03 22:50:43.811 7303-7303/com.mapcushion.android.mapcushionpingl I/﹕ byte 2: 6 02-03 22:50:43.811 7303-7303/com.mapcushion.android.mapcushionpingl I/﹕ byte 3: 26 02-03 22:50:43.811 7303-7303/com.mapcushion.android.mapcushionpingl I/﹕ byte 4: -1 02-03 22:50:43.811 7303-7303/com.mapcushion.android.mapcushionpingl I/﹕ byte 5: 76 02-03 22:50:43.811 7303-7303/com.mapcushion.android.mapcushionpingl I/﹕ byte 6: 0 02-03 22:50:43.821 7303-7303/com.mapcushion.android.mapcushionpingl I/﹕ byte 7: 2 02-03 22:50:43.821 7303-7303/com.mapcushion.android.mapcushionpingl I/﹕ byte 8: 21 02-03 22:50:43.831 7303-7303/com.mapcushion.android.mapcushionpingl I/﹕ byte 9: 47 02-03 22:50:43.831 7303-7303/com.mapcushion.android.mapcushionpingl I/﹕ byte 10: 35 02-03 22:50:43.831 7303-7303/com.mapcushion.android.mapcushionpingl I/﹕ byte 11: 68 02-03 22:50:43.831 7303-7303/com.mapcushion.android.mapcushionpingl I/﹕ byte 12: 84 02-03 22:50:43.831 7303-7303/com.mapcushion.android.mapcushionpingl I/﹕ byte 13: -49 02-03 22:50:43.831 7303-7303/com.mapcushion.android.mapcushionpingl I/﹕ byte 14: 109 02-03 22:50:43.831 7303-7303/com.mapcushion.android.mapcushionpingl I/﹕ byte 15: 74 02-03 22:50:43.831 7303-7303/com.mapcushion.android.mapcushionpingl I/﹕ byte 16: 15 02-03 22:50:43.841 7303-7303/com.mapcushion.android.mapcushionpingl I/﹕ byte 17: -83 02-03 22:50:43.841 7303-7303/com.mapcushion.android.mapcushionpingl I/﹕ byte 18: -14 02-03 22:50:43.841 7303-7303/com.mapcushion.android.mapcushionpingl I/﹕ byte 19: -12 02-03 22:50:43.841 7303-7303/com.mapcushion.android.mapcushionpingl I/﹕ byte 20: -111 02-03 22:50:43.841 7303-7303/com.mapcushion.android.mapcushionpingl I/﹕ byte 21: 27 02-03 22:50:43.841 7303-7303/com.mapcushion.android.mapcushionpingl I/﹕ byte 22: -87 02-03 22:50:43.841 7303-7303/com.mapcushion.android.mapcushionpingl I/﹕ byte 23: -1 02-03 22:50:43.851 7303-7303/com.mapcushion.android.mapcushionpingl I/﹕ byte 24: -90 02-03 22:50:43.851 7303-7303/com.mapcushion.android.mapcushionpingl I/﹕ byte 25: 0 02-03 22:50:43.851 7303-7303/com.mapcushion.android.mapcushionpingl I/﹕ byte 26: 4 02-03 22:50:43.851 7303-7303/com.mapcushion.android.mapcushionpingl I/﹕ byte 27: 0 02-03 22:50:43.851 7303-7303/com.mapcushion.android.mapcushionpingl I/﹕ byte 28: 101 02-03 22:50:43.851 7303-7303/com.mapcushion.android.mapcushionpingl I/﹕ byte 29: -76 02-03 22:50:43.851 7303-7303/com.mapcushion.android.mapcushionpingl I/﹕ byte 30: 0 ... (all 0''s) 02-03 22:50:43.882 7303-7303/com.mapcushion.android.mapcushionpingl I/﹕ byte 61: 0 02-03 22:50:43.882 7303-7303/com.mapcushion.android.mapcushionpingl I/﹕ scanned record: 62 02-03 22:50:43.882 7303-7303/com.mapcushion.android.mapcushionpingl I/﹕ Identifier check: 255 == 2 02-03 22:50:43.882 7303-7303/com.mapcushion.android.mapcushionpingl I/﹕ Length of data : 76==21 02-03 22:50:43.882 7303-7303/com.mapcushion.android.mapcushionpingl I/﹕ scanned record: 62 02-03 22:50:43.882 7303-7303/com.mapcushion.android.mapcushionpingl I/﹕ Identifier check: 76 == 2 02-03 22:50:43.882 7303-7303/com.mapcushion.android.mapcushionpingl I/﹕ Length of data : 0==21 02-03 22:50:43.882 7303-7303/com.mapcushion.android.mapcushionpingl I/﹕ scanned record: 62 02-03 22:50:43.882 7303-7303/com.mapcushion.android.mapcushionpingl I/﹕ Identifier check: 0 == 2 02-03 22:50:43.882 7303-7303/com.mapcushion.android.mapcushionpingl I/﹕ Length of data : 2==21 02-03 22:50:43.882 7303-7303/com.mapcushion.android.mapcushionpingl I/﹕ scanned record: 62 02-03 22:50:43.882 7303-7303/com.mapcushion.android.mapcushionpingl I/﹕ Identifier check: 2 == 2 02-03 22:50:43.882 7303-7303/com.mapcushion.android.mapcushionpingl I/﹕ Length of data : 21==21 02-03 22:50:43.882 7303-7303/com.mapcushion.android.mapcushionpingl I/System.out﹕ -------------output------ : 2F234454-CF6D-4A0F-ADF2-F4911BA9FFA6 maj: 4 min: 101 02-03 22:50:43.912 7303-7303/com.mapcushion.android.mapcushionpingl I/﹕ Calling stopLeScan
smartwatch(不工作):
2-03 22:53:37.374 6177-6189/com.mapcushion.android.mapcushionpingl D/BluetoothAdapter﹕ onScanResult() - Device=E5:E0:20:CF:63:32 RSSI=-46 02-03 22:53:37.376 6177-6177/com.mapcushion.android.mapcushionpingl I/﹕ INSIDE ONLESCAN 02-03 22:53:37.376 6177-6177/com.mapcushion.android.mapcushionpingl I/﹕ scanned record: 62 02-03 22:53:37.376 6177-6177/com.mapcushion.android.mapcushionpingl I/﹕ byte 0: 2 02-03 22:53:37.376 6177-6177/com.mapcushion.android.mapcushionpingl I/﹕ byte 1: 1 02-03 22:53:37.376 6177-6177/com.mapcushion.android.mapcushionpingl I/﹕ byte 2: 0 02-03 22:53:37.376 6177-6177/com.mapcushion.android.mapcushionpingl I/﹕ byte 3: 0 02-03 22:53:37.376 6177-6177/com.mapcushion.android.mapcushionpingl I/﹕ byte 4: 0 02-03 22:53:37.376 6177-6177/com.mapcushion.android.mapcushionpingl I/﹕ byte 5: 0 02-03 22:53:37.376 6177-6177/com.mapcushion.android.mapcushionpingl I/﹕ byte 6: 0 ... (all 0''s) 02-03 22:53:37.378 6177-6177/com.mapcushion.android.mapcushionpingl I/﹕ byte 61: 0 02-03 22:53:37.378 6177-6177/com.mapcushion.android.mapcushionpingl I/﹕ scanned record: 62 02-03 22:53:37.378 6177-6177/com.mapcushion.android.mapcushionpingl I/﹕ Identifier check: 0 == 2 02-03 22:53:37.378 6177-6177/com.mapcushion.android.mapcushionpingl I/﹕ Length of data : 0==21 02-03 22:53:37.378 6177-6177/com.mapcushion.android.mapcushionpingl I/﹕ scanned record: 62 02-03 22:53:37.378 6177-6177/com.mapcushion.android.mapcushionpingl I/﹕ Identifier check: 0 == 2 02-03 22:53:37.378 6177-6177/com.mapcushion.android.mapcushionpingl I/﹕ Length of data : 0==21 02-03 22:53:37.378 6177-6177/com.mapcushion.android.mapcushionpingl I/﹕ scanned record: 62 02-03 22:53:37.378 6177-6177/com.mapcushion.android.mapcushionpingl I/﹕ Identifier check: 0 == 2 02-03 22:53:37.378 6177-6177/com.mapcushion.android.mapcushionpingl I/﹕ Length of data : 0==21 02-03 22:53:37.378 6177-6177/com.mapcushion.android.mapcushionpingl I/﹕ scanned record: 62 02-03 22:53:37.378 6177-6177/com.mapcushion.android.mapcushionpingl I/﹕ Identifier check: 0 == 2 02-03 22:53:37.378 6177-6177/com.mapcushion.android.mapcushionpingl I/﹕ Length of data : 0==21 02-03 22:53:37.643 6177-6177/com.mapcushion.android.mapcushionpingl I/﹕ Calling stopLeScan 02-03 22:53:37.643 6177-6177/com.mapcushion.android.mapcushionpingl D/BluetoothAdapter﹕ stopLeScan() 02-03 22:53:37.743 6177-6177/com.mapcushion.android.mapcushionpingl I/﹕ Calling stopLeScan 02-03 22:53:37.743 6177-6177/com.mapcushion.android.mapcushionpingl D/BluetoothAdapter﹕ stopLeScan()
解决方法
0201000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
虽然Nexus 7将其读作一个非常不同的字节序列:
02011a0bff4c0009060102c0a801130000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
我必须得出结论,手表没有正确读取BLE制造商的广告 – 它在两个字节后截断它们.
问题可能是MTK6572 ROM,硬件或两者协同工作的方式.为了其他人,可能值得记录完整的手表配置.
android – ActionBar边框在叠加时不会消失
这是一张图片,可以更清楚地看到它:
在API 14上:
在API 16上:
设计如下:操作栏应该是透明的并且处于叠加模式,并且在其后面有徽标的背景
<ImageView android:id="@+id/action_bar_background" android:layout_width="match_parent" android:layout_height="@dimen/action_bar_accueil_total_height" android:layout_alignParentTop="true" android:contentDescription="@string/action_bar" android:scaleType="fitXY" android:src="@drawable/actionbar_logo_extended" /> <ImageView android:id="@+id/home_gallica_logo" android:layout_width="@dimen/largeur_logo_carrousel" android:layout_height="@dimen/action_bar_accueil_total_height" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" android:contentDescription="@string/action_bar" android:src="@drawable/logo_fullcolor" />
一些准确性:我使用ABS,但这似乎不是问题的根源,因为切换到v7支持库做了完全相同的事情.
有谁知道如何删除这个底部边框?
解决方法
我们今天的关于在游戏中,如果我从窗口小部件运行,图像会在Android设备上消失,但在第一次安装APK时不会消失的分享就到这里,谢谢您的阅读,如果想了解更多关于ajax在某些Android设备上运行,而不是在其他设备上运行、Android adb安装apk时提示Invalid APK file的问题、Android Beacon Library在一台Android 4.4设备上运行良好,但在另一台Android设备上运行良好、android – ActionBar边框在叠加时不会消失的相关信息,可以在本站进行搜索。
本文标签: