草庐IT

null_unspecified

全部标签

android - 未能将结果 ResultInfo{who_null,request=1,result=-1, data =Intent{( has extras )}} 传递给 Activity ;NullPointerException

我有两个类,它们的名称分别是Courses和MainActivity。MainActivity具有LAUNCHERActivity并且具有Gridlayout。类(class)具有默认Activity。当GridLayout单击类(class)界面时,用户正在根据他或她的类(class)程序填充View,因此创建类(class)对象。我想将此对象发送到MainActivity类。当我发送此对象时,我正在得到NullPointerException。我试图解决这个问题,但我不能。我需要专业的帮助。这是Courses.javapackagecom.example.classprogram;

android - fragment setuserVisibleHint true 但 getActivity 返回 null

我一直在fragment的setUserVisibleHint()方法内部做一些逻辑。我一直在检查isVisibleToUser是否为真,然后使用getActivity返回Activity。在我将支持库更新到最新版本(support:appcompat-v7:24.2.0)之前,它运行良好(100%的时间)。现在getActivity总是返回null。是否对解释此行为的支持库进行了一些更改?@OverridepublicvoidsetUserVisibleHint(booleanisVisibleToUser){super.setUserVisibleHint(false);if(is

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

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