Note that there are some explanatory texts on larger screens.

plurals
  1. POProgressDialog and AsyncTask gives me some errors
    text
    copied!<p>I am trying to use this code:</p> <ol> <li><p>When I am clicking on a imageButton, this will execute the goJournalArticles(View v) method:</p> <pre><code>public void goJournalArticles(View v) { new DownoadJournalsFinishedAsync().execute(); } </code></pre></li> </ol> <p>Then, I am doing some things and during this, I am showing the progressDialog:</p> <pre><code>class DownoadJournalsFinishedAsync extends AsyncTask&lt;String, String, ArrayList&lt;String&gt;&gt; { ProgressDialog dialog = new ProgressDialog(Journals.this); @Override protected void onPreExecute() { super.onPreExecute(); dialog.setMessage("Loading Articles. Please wait..."); dialog.setCancelable(false); dialog.show(); } @Override protected ArrayList&lt;String&gt; doInBackground(String... aurl) { String journalNameShort = localDatabase.getHistoryLastSelectedJournal(); int journalId = localDatabase.getJournalIdFromNameShort(journalNameShort); ArrayList&lt;String&gt; result = new ArrayList&lt;String&gt;(); try { infoCourrentIssue = serviceMDPI.JournalCurrentIssue(journalId); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } int issue =infoCourrentIssue.getIssue(); int volume = infoCourrentIssue.getVolume(); ArrayList&lt;Article&gt; articles = GetCurrentIssue(journalId,volume,issue); int size = articles.size(); for (int i=0;i&lt;size;i++) { result.add(Html.fromHtml(articles.get(i).getTitle()).toString()); } return result; } @Override protected void onPostExecute(ArrayList&lt;String&gt; result) { //View v = findViewById(R.id.Articles); Intent myIntent = new Intent(getBaseContext(), JournalArticles.class); myIntent.putExtra("articlesTitle", result); startActivityForResult(myIntent, 0); dialog.dismiss(); } } </code></pre> <p>But When I am trying to open a new activity with the intent, I am gotting this error:</p> <pre><code>03-05 12:08:47.724: E/AndroidRuntime(22249): FATAL EXCEPTION: main 03-05 12:08:47.724: E/AndroidRuntime(22249): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{milos.mdpi/milos.mdpi.JournalArticles}: java.lang.NullPointerException 03-05 12:08:47.724: E/AndroidRuntime(22249): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1785) 03-05 12:08:47.724: E/AndroidRuntime(22249): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1893) 03-05 12:08:47.724: E/AndroidRuntime(22249): at android.app.ActivityThread.access$1500(ActivityThread.java:135) 03-05 12:08:47.724: E/AndroidRuntime(22249): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1054) 03-05 12:08:47.724: E/AndroidRuntime(22249): at android.os.Handler.dispatchMessage(Handler.java:99) 03-05 12:08:47.724: E/AndroidRuntime(22249): at android.os.Looper.loop(Looper.java:150) 03-05 12:08:47.724: E/AndroidRuntime(22249): at android.app.ActivityThread.main(ActivityThread.java:4389) 03-05 12:08:47.724: E/AndroidRuntime(22249): at java.lang.reflect.Method.invokeNative(Native Method) 03-05 12:08:47.724: E/AndroidRuntime(22249): at java.lang.reflect.Method.invoke(Method.java:507) 03-05 12:08:47.724: E/AndroidRuntime(22249): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849) 03-05 12:08:47.724: E/AndroidRuntime(22249): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607) 03-05 12:08:47.724: E/AndroidRuntime(22249): at dalvik.system.NativeStart.main(Native Method) 03-05 12:08:47.724: E/AndroidRuntime(22249): Caused by: java.lang.NullPointerException 03-05 12:08:47.724: E/AndroidRuntime(22249): at android.app.Activity.findViewById(Activity.java:1732) 03-05 12:08:47.724: E/AndroidRuntime(22249): at milos.mdpi.JournalArticles.&lt;init&gt;(JournalArticles.java:13) 03-05 12:08:47.724: E/AndroidRuntime(22249): at java.lang.Class.newInstanceImpl(Native Method) 03-05 12:08:47.724: E/AndroidRuntime(22249): at java.lang.Class.newInstance(Class.java:1409) 03-05 12:08:47.724: E/AndroidRuntime(22249): at android.app.Instrumentation.newActivity(Instrumentation.java:1040) 03-05 12:08:47.724: E/AndroidRuntime(22249): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1777) 03-05 12:08:47.724: E/AndroidRuntime(22249): ... 11 more </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload