草庐IT

Out-Null

全部标签

android - Facebook SDK 错误 :Argument 'applicationId' cannot be null

我正在使用本指南https://developers.facebook.com/docs/android/getting-started.我在Facebook的开发者页面上创建了应用程序,并在开发者设置中添加了包名、哈希键。但是我收到了这个错误:Causedby:java.lang.NullPointerException:参数'applicationId'不能为空主要Activity:publicclassMainActivityextendsActionBarActivity{@OverrideprotectedvoidonCreate(BundlesavedInstanceSta

android - 如何在Android上解析 "unit-test"json(JSONObject == "null")?

我有一些问题。我已经创建了JSONParser并且需要对其进行单元测试。但是,如果我试图传递一个带有有效JSON副本的String对象,每次JSONObject(我的解析器的一部分)的值为null。这里是例子。我正在分配给字符串的JSON:publicclassJSONParserTest{privateJSONParserparser;privateTranslationstranslations;privateStringnounsAndAdjectivesJson="{\"head\":{},\"def\":[{\"text\":\"house\",\"pos\":\"noun\

android - 为什么 setOnQueryTextListener() 会出现 "on a null object reference"错误?

我正在尝试将搜索图标添加到工具栏,按下该图标将打开搜索栏。但是我试过的各种方法都不行,没有图标出现。现在我收到此错误,但找不到解决方案:java.lang.NullPointerException:Attempttoinvokevirtualmethod'voidandroid.support.v7.widget.SearchView.setOnQueryTextListener(android.support.v7.widget.SearchView$OnQueryTextListener)'onanullobjectreferenceatpl.michalz.hideonscrol

android - getExtras() 在应用程序级别(-class)返回 null

在我的Application级别上,我收到getExtras()的null,但在Activity级别上我可以看到他们正确。publicclassMyApplicationextendsApplication{@OverridepublicvoidonCreate(){super.onCreate();Intentintent=getPackageManager().getLaunchIntentForPackage("com.example.MyApp");if(intent!=null){StringmStaticWorldUrl=intent.getStringExtra("arg

android - 将小部件添加到现有 Xamarin Android 应用程序时 bundle savedInstanceState null

我有和现有android应用程序是用Xamarin开发的。它工作完美。我决定为我的应用程序创建一个小部件,并且我遵循了XamarinWidgetSample,http://forums.xamarin.com/discussion/22941...和VogelaWidgettutorial添加所需内容的指南。不幸的是,因为他们,应用程序开始崩溃并出现此异常Java.Lang.NullPointerException:Attempttoinvokevirtualmethod'voidandroid.support.v7.widget.ContentFrameLayout.setId(in

Android - 自定义复合组件中的 View 未膨胀(findByView 返回 null)

我用XML制作了一个自定义组件,由一个按钮和一个ImageView组成:Java源代码摘录:publicclassClearableCaptionedButtonextendsRelativeLayoutimplementsOnClickListener{...publicClearableCaptionedButton(Contextcontext,AttributeSetattrs){super(context,attrs);//somestuffthatworksfine}..protectedvoidonFinishInflate(){super.onFinishInflate

java - 当某些字节错误时,BitmapFactory.decodeStream(inputStream) 总是返回 null

我正在构建一个Android应用程序,但我目前无法从URL检索位图。这是我正在使用的代码:publicstaticBitmapbmpFromURL(URLimageURL){Bitmapresult=null;try{HttpURLConnectionconnection=(HttpURLConnection)imageURL.openConnection();connection.setDoInput(true);connection.connect();InputStreaminput=connection.getInputStream();result=BitmapFactory

解决Fastjson2 oom(Out Of Memory),支持大对象(LargeObject 1G)json操作

在使用Fastjson中的JSON.toJSONString时,如果对象数据太大(>64M)会出现OutOfMemory,查看源码发现为JSONWriter中的判断代码 其中maxArraySize默认最大为64M,如果超过了就会抛出oom错误 如果fastjson过多的使用内存,也可能导致java堆内存溢出,所以这里建议控制好json对象大小,避免过多过大对象做json操作。使默认的JSON操作支持到大对象(LargeObject1G)也可以使默认的JSON操作支持到大对象(1G),只需要配置好默认上下文对象(context.features)使用方法:JSON.config(LargeOb

java - 在 Java 中尝试从另一个类访问变量时获取 null

我有两个类,我想将触摸时的(地理点)变量从一个类传递到另一个类,这样我就可以计算用户当前位置与地理点之间的距离。长话短说:我的第一个类名为Session,第二个类名为Calculation-它们在同一个包中。我在主类中将变量声明为公共(public)变量。在触摸时,我将用户当前位置保存到名为userposition的(公共(public))地理点变量中。然后在第二节课我用Sessionpass=newSession();创建session实例。之后我尝试检索userposition变量:Geopointposition=pass.userposition;但它一直返回null并抛出异常

android - Camera.open() 返回NULL Android开发

我正在学习构建相机应用程序的教程http://developer.android.com/tools/device.html我调用Camera.open()返回null。我已经在list中声明了权限,我在模拟器和xyboard上都试过了,但我仍然得到null。有谁知道任何快速提示?Camerac=null;try{c=Camera.open()}catch(Exeptione){}returnc;请记住,我没有抛出异常,我只是返回NULL。 最佳答案 那是因为it'snotsupposedtothrowanexception.当没有