草庐IT

set_null

全部标签

Android InstrumentationTestCase getFilesDir() 返回 null

我正在使用InstrumentationTestCase对我的应用程序的组件进行单元测试。该组件将数据保存到内部存储并使用Context::fileList();检索保存的文件。我遇到以下问题:在应用程序(在设备上)中使用此方法效果非常好。但是当我尝试使用InstrumentationTestCase进行(Android-)单元测试(也在设备上)时,我在fileList()NullPointerException方法。我深入研究了android源代码,发现getFilesDir()(seesourcehere)返回null并导致此错误。重现代码如下:publicclassMyTestC

Android Google Plus getCurrentPerson 返回 null

当我调用plusClient.getCurrentPerson()时,我得到NULL。方法onConnected(Bundle...)在成功登录后调用:@OverridepublicvoidonConnected(Bundlebundle){if(plusClient.getCurrentPerson()==null){Log.e("DD","Personisnull!");}}我直接从eclipse(Window->Preferences->Android->Build)添加了SHA1。我不知道我做错了什么!来自EclipseADT的SHA1指纹已安装应用程序的客户端ID简单的API

java - Android FragmentActivity 在 getActionBar() 中返回 null

我在AndroidStudio中导入了一个名为Horizo​​ntalPaging的Android示例项目,当我运行它时它运行良好。但是当我将代码复制到我的代码中时,我在getActionBar()中得到一个空指针异常。我整天都在阅读有关这些问题的信息,但无法使其正常工作。尝试将示例的MainActivity中的整个代码复制到我的项目中,但没有任何改进,所以我猜测问题出在其他一些文件中,如list、样式等。MainActivity.java从示例项目复制importandroid.app.ActionBar;importandroid.app.FragmentTransaction;i

Python 之 Pandas merge() 函数、set_index() 函数、drop_duplicates() 函数和 tolist() 函数

文章目录一、merge()函数1.inner2.left和right3.outer二、set_index()函数三、drop_duplicates()函数四、tolist()函数五、视频数据分析案例1.问题要求2.解决过程在最开始,我们先导入常规的numpy和pandas库。importnumpyasnpimportpandasaspd为了方便维护,数据在数据库内都是分表存储的,比如用一个表存储所有用户的基本信息,一个表存储用户的消费情况。所以,在日常的数据处理中,经常需要将两张表拼接起来使用,这样的操作对应到SQL中是join,在Pandas中则是用merge来实现。这篇文章就讲一下merg

android - org.json.JSONObject$1 类型的值 null 无法转换为 JSONObject

我在使用OpenWeatherMapAPI时收到此异常错误。我只是想让result成为一个JSONObject,但是null不断出现。@OverrideprotectedvoidonPostExecute(Stringresult){super.onPostExecute(result);//What'scominginasresult...//Printedtotheconsole...//null{"coord":{"lon":-0.13,"lat":51.51},"weather":[{"id":800,"main":"Clear",//"description":"clears

java - Android RecyclerView Adapter 在单元测试中给出 null

我正在尝试使用AndroidJunit4测试RecyclerView,这是我的测试代码:packagecom.kaushik.myredmart.ui;//allincludes@RunWith(AndroidJUnit4.class)publicclassProductListActivityTest{@RulepublicActivityTestRulerule=newActivityTestRule(ProductListActivity.class);@TestpublicvoidensureListViewIsPresent()throwsException{ProductL

android - 方法 openOrCreateDatabase(String, int, null) 未定义

我正在尝试按如下方式打开数据库:SQLiteDatabasemyDatabase;myDatabase=openOrCreateDatabase("sudoku.db",Context.MODE_PRIVATE,null);当我在Service类中实现这段代码时它工作正常,但是当我尝试在GeneraterThread类的onPostExecute事件处理程序中实现它时,实现AsyncTask,我得到以下错误:方法openOrCreateDatabase(String,int,null)未定义类型GeneraterThread 最佳答案

Fragment中Android getSupportFragmentManager NULL指针异常

点击抽屉导航项目后,我尝试使用TabBar和ViewPager显示新fragment。问题是新创建的Fragment导致NULL指针异常viewPager.setAdapter(mAdapter);我在Fragment中卡在带有标签的滑动View上几个小时,但没有运气,有人可以帮我解决这个问题吗?对于可滑动的View,我遵循了本教程:http://www.androidhive.info/2013/10/android-tab-layout-with-swipeable-views-1/fragment代码在这里:importandroid.app.ActionBar;importan

android - getDrawingCache() 总是返回 null

我想使用DrawingCache捕获ImageView的内容。我写了下面的代码。iv1=(ImageView)findViewById(R.id.iv1);iv2=(ImageView)findViewById(R.id.iv2);iv1.setDrawingCacheEnabled(true);BitmapmyScreenshot=iv1.getDrawingCache();iv2.setImageBitmap(myScreenshot);但我在屏幕上只看到一张图片。后来才知道myScreenshot是null我看到很多关于同样问题的帖子,但没有合适的解决方案。我认为我们必须在lis

android - java.io.IOException : Received authentication challenge is null in ICS 4. 0.3

我正在尝试从服务器注销。但它返回“0”响应代码,但有此异常。我正在使用GET动词来执行此操作。LogCat10-1714:54:13.261:W/System.err(868):java.io.IOException:Receivedauthenticationchallengeisnull10-1714:54:13.284:W/System.err(868):atlibcore.net.http.HttpURLConnectionImpl.processAuthHeader(HttpURLConnectionImpl.java:397)10-1714:54:13.284:W/Syst