nullpointerexception

Android Camera Video intent returns null URI

╄→尐↘猪︶ㄣ 提交于 2019-12-22 13:56:40
问题 I recently got updated to Android 4.3 and the stock video camera started acting a little weird whenever I started it with an Intent from my app. At first it would just crash and say "Gallery stopped responding". After a little while, I was able to record a video, but clicking on done returned a null URI to my app, which made it crash! So I set out testing a 2.3.4 device with the same code. The video app returned a proper URI I could use on that device. The same code worked perfectly fine

How would I go about fixing a NullPointerException of the following code?

被刻印的时光 ゝ 提交于 2019-12-22 12:53:20
问题 I have this code and when I run the script, I pass in valid parameters, but I keep on getting a NPE. Help? Code: private static Date getNearestDate(List<Date> dates, Date currentDate) { long minDiff = -1, currentTime = currentDate.getTime(); Date minDate = null; if (!dates.isEmpty() && currentDate != null) { for (Date date : dates) { long diff = Math.abs(currentTime - date.getTime()); if ((minDiff == -1) || (diff < minDiff)) { minDiff = diff; minDate = date; } } } return minDate; } I get the

java.lang.NullPointerException while getting a filepath in Java (executing through a jar file)

元气小坏坏 提交于 2019-12-22 11:29:07
问题 I am getting an NPE at the point of getting path of a File (an sh file in assets folder). I have tried to read about NPE i detail from the following thread, but this actually could not solve my problem. What is a NullPointerException, and how do I fix it? Following is my code snippet: File absPathofBash; url = ClassLoader.class.getResource("assets/forbackingup.sh"); absPathofBash = new File(url.getPath()); Later I'm using it in a ProcessBuilder , as ProcessBuilder pb = new ProcessBuilder(url

Does Google play services version being out-dated not let the app to run?

情到浓时终转凉″ 提交于 2019-12-22 10:57:36
问题 I am developing a simple application to show a map. For this i am testing my application on a real device as: Samsung Galaxy Europa (Android 2.2) . Unfortunately my application is being closed/crashed forcely with lots of errors being viewed in logcat (i am mentioning along with my code). I have included google_play_services_lib as per the rules but in-vain. And Yes i have scratched every bit of solutions mentioned here like: Solution 1 - Google play services out of date Solution 2 - Google

Exception Dispatching Input Event and Null Pointer Exception on SwipeRefreshLayout Pull down

走远了吗. 提交于 2019-12-22 10:56:14
问题 I have a swipe to refresh layout (part of android.support.v4 revision 19.1), and when I swipe down on the layout I can get to the point where the top part is full, but swiping down any further will cause the app to crash, and the logcat points to no specific line in my code. Since SwipeRefreshLayout is only a couple of months old, their is not a lot of information on the internet to help me figure out what the problem is. Before I was having trouble adding the support v4 revision 19.1 to my

ArrayList Null Pointer Exception in onPostExecute()

六眼飞鱼酱① 提交于 2019-12-22 09:59:18
问题 Getting NullPointerException in ArrayList. I'm using the line below to log size of ArrayList but I always get NPE. What could be the reason? Log.d("catArrayList:Size:New", ""+categoryArrayList.size()); Here is some more code : protected void onPostExecute(Boolean result) { dialog.cancel(); Log.d("catArrayList:Size", ""+categoryArrayList.size()); Log.d("typArrayList:Size", ""+typeArrayList.size()); Log.d("serArrayList:Size", ""+serviceArrayList.size()); Log.d("cArrayList:Size", ""+cArrayList

Creating Buttons Dynamically inside a for loop for use in a scrollview

爷,独闯天下 提交于 2019-12-22 08:55:50
问题 I have an issue with creating buttons dynamically. I used the help provided by How can I dynamically create a button in Android? Although is does help tremendously it isn't exactly working with my specific situation. I am trying to create an array of buttons inside of a scroll view. These buttons will basically be created on the fly based off the answer to the query from a sqlite database. I havent implemented the database as of yet but im just using a for loop with a set variable to create

What's causing this NullpointerException?

ε祈祈猫儿з 提交于 2019-12-22 08:46:31
问题 I've received a crash report with the following log content: java.lang.NullPointerException at android.webkit.PluginFullScreenHolder.show(PluginFullScreenHolder.java:85) at android.webkit.WebView$PrivateHandler.handleMessage(WebView.java:8553) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:4340) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke

Get Fragment by Tag

限于喜欢 提交于 2019-12-22 08:35:15
问题 I am using a FragmentPagerAdapter to create a multi-pages UI with different fragments. What I want to do is to find the Fragment using the position of the Fragment. I have applied the method of finding the nametag of fragments and use .FindFragmentbyTag() but the .FindFragmentbyTag always return me null value. The structure seems to be correct so I am not sure why I get null values, please look through and help is appreciated. Here is the code MainActivity.java public void onCreate(Bundle

getActivity() returns a null in my ActivityInstrumentationTestCase2 class

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-22 08:05:11
问题 I want my app to perform the following test in the code with ActivityInstrumentationTestCase2. The problem is the getActivity() method returns a null. This results in a NullPointerException at the line directly underneath the line that contains getActivity(). As a result, the test cannot run. I don't know why it is doing that. I have already tried changing @Before to @Override but the problem continues. Here is the actual Test class: package com.example.guy.smsclassprojecttest; import android