-edit 2. Tested this on my mobile works as intended. Stupid android avd  I am getting a error and i am not quite sure how to fix it. I could remove the need for caching the image but that would increase the bandwidth needed for the application. My current code should work but it is throwing a NullPointerException here is the error  java.lang.NullPointerException: Attempt to invoke virtual method 'java.io.File android.content.Context.getCacheDir()' on a null object reference                                                                                            at android.content.ContextWrapper.getCacheDir(ContextWrapper.java:232)                                                                                            at com.program.programmy.application.FileCache.&lt;init&gt;(FileCache.java:18)   and this is the code causing the problem is the one surrounded by **  line 18  public FileCache(Context context) {     // Find the dir to save cached images     if (android.os.Environment.getExternalStorageState().equals(             android.os.Environment.MEDIA_MOUNTED))         cacheDir = new File(                 android.os.Environment.getExternalStorageDirectory(),                 "ParseListViewImgTxt");     else         **cacheDir = context.getCacheDir();**     if (!cacheDir.exists())         cacheDir.mkdirs(); }   if someone could help out with this one little thing my program should work no problem. cheers  -Edit  This is only when i try to leave the list intent to look at a single object. Here is some more code from the area that prompts the error  view.setOnClickListener(new OnClickListener() {             @Override             public void onClick(View v) {                  Intent intent = new Intent(context, SingleItemView.class);                 context.startActivity(intent);             }         });   Also here is a link to something similar that i am doing except no one is having the problem i am
129
What are Null Pointer Exceptions (java.lang.NullPointerException) and what causes them?  What methods/tools can be used to determine the cause so that you stop the exception from causing the program to terminate prematurely?
21759
I have a Visualforce page that renders perfectly as a PDF that I'd like to attach to an opportunity record and to attach to an email.  Whenever the code gets to getContent(), I keep getting an error saying      Too many nested getContent calls   Below, you can see the code is very simple.  Just pulls data to fit into the VF page in the substitution blanks then tries to create the PDF.  Looking at the debug log, the call to getContent() only happens once.  I'm stumped!  Thanks for your ideas...  public with sharing class GenerateThankYouLetterAsPDF {   // a handful of fields that are {!field} substitutions on the VF page     public id oppID {get; set;}     public string giftAmount {set; get;}     public string giftDate {set; get;}     //  etc...       public GenerateThankYouLetterAsPDF() {         id oppID = id.valueof( ApexPages.currentPage().getParameters().get('id') );               // set the values of field substituions           string filename = 'donation.pdf';          // Generate the PDF          PageReference pdf = ApexPages.currentPage();         system.debug ('calling getContent...');         blob b = pdf.getContent();   }                 }
53765
When I parse my xml file (variable f) in this method, I get an error      C:\Documents and Settings\joe\Desktop\aicpcudev\OnlineModule\map.dtd (The system cannot find the path specified)   I know I do not have the dtd, nor do I need it.  How can I parse this File object into a Document object while ignoring DTD reference errors?  private static Document getDoc(File f, String docId) throws Exception{     DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();     DocumentBuilder db = dbf.newDocumentBuilder();     Document doc = db.parse(f);       return doc; }
11494
App version 1.0.27  If you the notification pane and click on the loading icon while it's spinning, the app will cause the app to crash.  03-26 22:51:08.331 E/AndroidRuntime(5927): FATAL EXCEPTION: main 03-26 22:51:08.331 E/AndroidRuntime(5927): java.lang.ArrayIndexOutOfBoundsException: length=0; index=-1 03-26 22:51:08.331 E/AndroidRuntime(5927): at java.util.ArrayList.get(ArrayList.java:310) 03-26 22:51:08.331 E/AndroidRuntime(5927): at com.stackexchange.marvin.ui.BaseActivity$3.onItemClick(BaseActivity.java:266) 03-26 22:51:08.331 E/AndroidRuntime(5927): at android.widget.AdapterView.performItemClick(AdapterView.java:298) 03-26 22:51:08.331 E/AndroidRuntime(5927): at android.widget.AbsListView.performItemClick(AbsListView.java:1100) 03-26 22:51:08.331 E/AndroidRuntime(5927): at android.widget.AbsListView$PerformClick.run(AbsListView.java:2788) 03-26 22:51:08.331 E/AndroidRuntime(5927): at android.widget.AbsListView$1.run(AbsListView.java:3463) 03-26 22:51:08.331 E/AndroidRuntime(5927): at android.os.Handler.handleCallback(Handler.java:730) 03-26 22:51:08.331 E/AndroidRuntime(5927): at android.os.Handler.dispatchMessage(Handler.java:92) 03-26 22:51:08.331 E/AndroidRuntime(5927): at android.os.Looper.loop(Looper.java:137) 03-26 22:51:08.331 E/AndroidRuntime(5927): at android.app.ActivityThread.main(ActivityThread.java:5103) 03-26 22:51:08.331 E/AndroidRuntime(5927): at java.lang.reflect.Method.invokeNative(Native Method) 03-26 22:51:08.331 E/AndroidRuntime(5927): at java.lang.reflect.Method.invoke(Method.java:525) 03-26 22:51:08.331 E/AndroidRuntime(5927): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737) 03-26 22:51:08.331 E/AndroidRuntime(5927): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 03-26 22:51:08.331 E/AndroidRuntime(5927): at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:126) 03-26 22:51:08.331 E/AndroidRuntime(5927): at dalvik.system.NativeStart.main(Native Method)   (Think I should calm down on finding bugs for a little while? :P)
103112
When and why would somebody do the following:  doSomething( (MyClass) null );   Have you ever done this? Could you please share your experience?
7315
Recently, apps that are fine an hour ago now crash when I open them. The crash report message seems to be caused by a null pointer exception (NPE) in com.google.android.trichromelibrary. Apps affected for me:  Gmail Dashlane  Is it just me, or is there actually something wrong with the library? How can I fix these affected apps? Crash report: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** Build fingerprint: 'Xiaomi/polaris/polaris:10/QKQ1.190828.002/20.9.4:user/release-keys' Revision: '0' ABI: 'arm64' Timestamp: ... pid: ..., tid: ..., name: com.dashlane &gt;&gt;&gt; com.dashlane &lt;&lt;&lt; uid: ... signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0 Cause: null pointer dereference          ...  backtrace:     #00 pc 00000000038621f0 /data/app/ com.google.android.trichromelibrary 438909034-YaxP9ttrIDcQBfleP5vm7Q==/base.apk! libmonochrome_64.so (offset 0x646000) (BuildId: ... )  (click  for the screenshot of the bug report)
58610
This is a follow-up to .     When I click a link to an SE site in the Android app, it gives me an "open with" pop-up that has two options:         Chrome   Stack Exchange         I can then choose to open SE posts like this "Just once" or "Always."      The problem is that when I set the SE app to "always," and I click "open in browser,"   Except, the app crashes when trying to open it in browser.  LogCat (just right after selecting "Open in browser")  01-22 18:03:36.354: E/AndroidRuntime(16064): FATAL EXCEPTION: main 01-22 18:03:36.354: E/AndroidRuntime(16064): Process: com.stackexchange.marvin, PID: 16064 01-22 18:03:36.354: E/AndroidRuntime(16064): java.lang.NullPointerException: Attempt to invoke interface method 'int java.util.List.size()' on a null object reference 01-22 18:03:36.354: E/AndroidRuntime(16064):    at com.stackexchange.marvin.utils.Helpers.getNonMarvinViewIntent(Helpers.java:452) 01-22 18:03:36.354: E/AndroidRuntime(16064):    at com.stackexchange.marvin.ui.question.QuestionDialog$1.onClick(QuestionDialog.java:39) 01-22 18:03:36.354: E/AndroidRuntime(16064):    at com.android.internal.app.AlertController$AlertParams$3.onItemClick(AlertController.java:1108) 01-22 18:03:36.354: E/AndroidRuntime(16064):    at android.widget.AdapterView.performItemClick(AdapterView.java:310) 01-22 18:03:36.354: E/AndroidRuntime(16064):    at android.widget.AbsListView.performItemClick(AbsListView.java:1145) 01-22 18:03:36.354: E/AndroidRuntime(16064):    at android.widget.AbsListView$PerformClick.run(AbsListView.java:3066) 01-22 18:03:36.354: E/AndroidRuntime(16064):    at android.widget.AbsListView$3.run(AbsListView.java:3903) 01-22 18:03:36.354: E/AndroidRuntime(16064):    at android.os.Handler.handleCallback(Handler.java:739) 01-22 18:03:36.354: E/AndroidRuntime(16064):    at android.os.Handler.dispatchMessage(Handler.java:95) 01-22 18:03:36.354: E/AndroidRuntime(16064):    at android.os.Looper.loop(Looper.java:148) 01-22 18:03:36.354: E/AndroidRuntime(16064):    at android.app.ActivityThread.main(ActivityThread.java:5417) 01-22 18:03:36.354: E/AndroidRuntime(16064):    at java.lang.reflect.Method.invoke(Native Method) 01-22 18:03:36.354: E/AndroidRuntime(16064):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 01-22 18:03:36.354: E/AndroidRuntime(16064):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)   I suspect it's related to , but not sure.  Specs:   Device model: Nexus 5 Android version: Android 6.0.1 SE app version: 1.0.82 (beta) Installed browser: Chrome 47.0.2526.83 (latest at current writing)
38862
In my application I load resources in this manner:  WinProcessor.class.getResource("repository").toString();   and this gives me:  file:/root/app/repository   (and I replace "file:" with empty string)   This works fine when I run my application from the IDE, but when I run the jar of my application:  java -jar app.jar   The path becomes:  jar:/root/app.jar!/repository   is there any way to solve this problem?  I'll use the "repository" dir name in order to create this:  ConfigurationContext ctx = (ConfigurationContext) ConfigurationContextFactory.createConfigurationContextFromFileSystem(repositoryString, null);   In the same manner, I'll get one file name (instead of a dir) and I'll use it this way:  System.setProperty("javax.net.ssl.trustStore", fileNameString)
46094
I am trying to display a list of all files found in the selected directory (and optionally any subdirectories). The problem I am having is that when the GetFiles() method comes across a folder that it cannot access, it throws an exception and the process stops.  How do I ignore this exception (and ignore the protected folder/file) and continue adding accessible files to the list?  try {     if (cbSubFolders.Checked == false)     {         string[] files = Directory.GetFiles(folderBrowserDialog1.SelectedPath);         foreach (string fileName in files)             ProcessFile(fileName);     }     else     {         string[] files = Directory.GetFiles(folderBrowserDialog1.SelectedPath, "*.*", SearchOption.AllDirectories);         foreach (string fileName in files)             ProcessFile(fileName);     }     lblNumberOfFilesDisplay.Enabled = true; } catch (UnauthorizedAccessException) { } finally {}
59202
I am getting an error while updating as a root. After Update log below error was shown in terminal.   AppStream system cache was updated, but problems were found: Metadata files have errors: /var/cache/app-info/xmls/fwupd.xml Reading package lists... Done E: Problem executing scripts APT::Update::Post-Invoke-Success 'if /usr/bin/test -w /var/cache/app-info -a -e /usr/bin/appstreamcli; then appstreamcli refresh-cache &gt; /dev/null; fi' E: Sub-process returned an error code   I followed  answer and executed sudo apt install appstream/xenial-backports.  My appstream package is already updated:-  $ appstreamcli --version AppStream CLI tool version: 0.10.6   After, force refreshing the cache data. I am getting the following error:-  $ sudo appstreamcli refresh --force AppStream system cache was updated, but problems were found: Metadata files have errors: /var/cache/app-info/xmls/fwupd.xml
71264
I'm wondering if it's possible to recover files from the Google Chrome cache from an Android phone, specifically, an HTC One S running Android 4.0.2.  I'm trying to recover the stylesheet from a site whose data has been partially lost, and of course this phone is the only device to have accessed it today before the crash.
2516
I am trying to get a FileInputStream object on an image that the user selects from the picture gallery. This is the android URI returned by android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI  content://media/external/images/media/3   When I try to construct a java URI object from this object, I get an IllegalArgumentException with the exception description Expected file scheme in URI: content://media/external/images/media/3 whereas the android URI shows the scheme as content  Update: Never found a solution for the original question. But if you want the byte stream of an image in the pictures gallery, this piece of code will do that.  Bitmap bitmap = Media.getBitmap(getContentResolver(), imageUri); ByteArrayOutputStream bytes = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 40, bytes); ByteArrayInputStream fileInputStream = new ByteArrayInputStream(bytes.toByteArray());
17386
I know the file needs to be where the getClass().getResource(filename) can find it, but I don't know where that is.  I'm interested both in where to put the files on the filesystem itself, and how to go about using Eclipse's functionality to set up the resources.
120685
It seems to me that a lot of my debugging time is spent chasing down null-reference exceptions in complex statements. For instance:  For Each game As IHomeGame in _GamesToOpen.GetIterator()   Why, when I get a NullReferenceException, can I get the line number in the stack trace, but not the name of the object that equals null. In other words, why:  Object reference not set to an instance of an object.   instead of  _GamesToOpen is not set to an instance of an object.   or  Anonymous object returned by _GamesToOpen.GetIterator() is null.   or  game was set to null.   Is this strictly a design choice, meant to protect the anonymity of the code or is there a compelling reason in compiler design not to include this information in the debug-time exception?
18864
Is there any way other than looping through the Files to check whether the folder or files exist in document library using clientcontext - client object model..  Can someone confirm me whether the below code will work or not. Or will it create any exception??  using(var clientContext = new ClientContext(site))  {  Web web = clientContext.Web;  Microsoft.SharePoint.Client.File file = web.GetFileByServerRelativeUrl("/site/doclib/folder/filename.ext");  bool bExists = false;  try { clientContext.Load(file);  clientContext.ExecuteQuery();   bExists = file.Exists;  } catch{ }  if (bExists ) { . .  }
99190
I have a node object with image field named field_image. When I do  $node   -&gt;get('field_image')   -&gt;first()   -&gt;getValue()   I get array with some properties instead of entity object. The array looks like this:  'target_id' =&gt; string '8' (length=1) 'alt' =&gt; string '' (length=0) 'title' =&gt; string '' (length=0) 'width' =&gt; string '587' (length=3) 'height' =&gt; string '458' (length=3) '_loaded' =&gt; boolean true   '_accessCacheability' =&gt;      object(Drupal\Core\Cache\CacheableMetadata)[1092]       protected 'cacheContexts' =&gt;          array (size=0)           ...       protected 'cacheTags' =&gt;          array (size=0)           ...       protected 'cacheMaxAge' =&gt; int -1   Do I have to manullay load the file entity using target_id or there is a way to automatically get referenced entity object from instance of Drupal\image\Plugin\Field\FieldType\ImageItem?  Why the referenced entity is not accessible via getter? It could be lazy loaded if it's not available immediately.
68276
In my page constructor I call a method isFirstPageLoaded, to  check if the loaded page is the first page of the wizard.   private final PageReference FIRSTPAGE = Page.Maintenance_Lock_1;   private void isFirstPageLoaded() {          if(ApexPages.currentPage()!=this.FIRSTPAGE) {              throw new MaintenanceLockException(this.FIRSTPAGE + ' --- ' + ApexPages.currentPage());          }      }   The problem is: Even if I open the first page of the wizard, the exception is thrown. How can I compare two PageReferences? I would like to avoid to parse the URLs and remove parameters etc...