草庐IT

dev-null

全部标签

android - getSupportActionBar() 使用 Robolectric 返回 null

当我通过基于Roboelectric和JUnit的测试用例调用方法getSupportActionBar()时,它返回null。这是我的简单测试用例:packagecom.mobile.test;importstaticorg.hamcrest.CoreMatchers.equalTo;importstaticorg.junit.Assert.assertEquals;importstaticorg.junit.Assert.assertThat;importorg.junit.Test;importorg.junit.runner.RunWith;importorg.robolect

android - getApplicationContext() 在服务中返回 null

我在自己的进程中有一个服务,我在list中声明了它:但是onStartCommand我试图获取一个ApplicationContext,但它总是返回null,我能忘记什么吗?publicintonStartCommand(Intentintent,intflags,intstartId){android.os.Debug.waitForDebugger();ContextmContext=getApplicationContext();returnService.START_STICKY;}然后我就这样开始了:startService(newIntent(getApplicationC

android - 如何在onActivityresult中获取图片路径(Intent数据为null)

我必须启动相机,当用户拍完照片后,我必须拍摄并在View中显示。查看http://developer.android.com/guide/topics/media/camera.html我做了:protectedvoidonCreate(BundlesavedInstanceState){super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);bLaunchCamera=(Button)findViewById(R.id.launchCamera);bLaunchCamera.setOnClic

c# - Xamarin "attempt to invoke virtual method ' void android.view.View.unFocus (android.view.View )' on a null object reference"

我正在使用Xamarin.Forms开发一个应用程序以供跨平台使用。最近我更新了Mac上的XamarinStudio以及更新了NuGet包。我现在收到此错误:尝试在空对象引用上调用虚拟方法“voidandroid.view.View.unFocus(android.view.View)”。(请参阅下面的堆栈跟踪)当离开(或重新呈现)除RootView之外的任何页面时,会发生这种情况。我认为我没有更改导航或页面呈现的任何部分。如果这有点含糊,我很抱歉,从堆栈跟踪来看,这不是从我的代码开始的(以任何可跟踪的方式)。而且我不确定从哪里开始调试。任何建议都会非常有帮助!堆栈跟踪---Endof

android - Intent.getAction() 正在抛出 Null + Android

我已经为某种警报应用程序编写了BroadcastReceiver。在onReceive方法中,我正在阅读Intent.getAction()。它在所有版本中都运行良好*除了在SDK版本1.5中抛出空指针异常*。我正在调用broadcastReceiver的另一个Activity中设置操作。这个你能帮我吗。下面是接收器和Activity类的代码fragment,ProfileActivity.javapublicstaticfinalStringSTARTALARMACTION="android.intent.driodaceapps.action.STARTPROFILE";publi

android - 如果不带recycle()设置myBitmap = null,带recycle()有什么区别

这个问题在这里已经有了答案:Diffb/wbitmap.recycle()andbitmap=null(3个答案)关闭9年前。我看到两条线总是在一起:myBitmap.recycle();myBitmap=null;如果我只使用:myBitmap=null;有什么区别?谢谢。

android - 为什么 imageView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);和<应用程序android :hardwareAccelerated ="false" have different effect?

不知道为什么要设置使用svg-android我看不到图像(由于硬件加速问题?),但如果我设置imageView.setLayerType(View.LAYER_TYPE_SOFTWARE,null);我可以让它工作。View.LAYER_TYPE_SOFTWARE是否禁用硬件加速? 最佳答案 直接回答你的问题(DoesView.LAYER_TYPE_SOFTWAREdisablesthehardwareaccelerationornot?)是的。它实际上禁用了硬件加速,但仅在View级别,即在您的情况下,在ImageView中禁用了

java - 测试 getJSONArray 是否为 null

我的代码提取了JSONObject的结果,但是,有时,i值不以1开头,并且我有这样的错误:org.json.JSONException:Novaluefor1我的代码:JSONObjectobj=newJSONObject(result);for(inti=1;i我想在提取之前测试目标代码(i)是否存在。我该怎么做? 最佳答案 使用obj.optJSONArray(name)如果名称不存在,响应将为null。JSONObjectobj=newJSONObject(result);for(inti=1;i

android - GPS 图标在 locationManager.removeUpdates() 之后仍然闪烁并将 locationManager 设置为 null

我正在开发位置跟踪应用程序。但是我通过做两件事停止获取位置更新......locationManager.removeUpdates(this);和将locationManager引用设置为null。这将停止获取我想要的位置坐标...但问题是gps图标仍在闪烁......这会耗尽设备的电池。所以请帮我停止这个GPS修复... 最佳答案 如果您在mapView中显示您的位置和/或指南针,则必须禁用它们。如果您不这样做,GPS仍处于Activity状态。例如:privateMapViewmapView;privateMyLocation

VUE+element UI :TypeError: Cannot read properties of null (reading ‘setAttribute‘)

报错提示:element-ui.common.js:2436UncaughtTypeError:Cannotreadpropertiesofnull(reading'setAttribute')atVueComponent.removeTabindex(element-ui.common.js:2436:1)atVueComponent.hide(element-ui.common.js:2334:1)atObject.eval[asdocumentHandler](clickoutside.js:39:1)ateval(clickoutside.js:25:1)atArray.forEach