Note that there are some explanatory texts on larger screens.

plurals
  1. POCannot start intent from different activity
    primarykey
    data
    text
    <p>I have this setup in my code.</p> <p>XML:</p> <pre><code> &lt;Button android:id="@+id/planTrip" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignRight="@+id/clearDestination" android:layout_below="@+id/destination" android:onClick="buttonCalls" android:text="@string/plan_trip" /&gt; </code></pre> <p>MainActivity</p> <pre><code> public void buttonCalls(View view) { Utils util = new Utils(); switch (view.getId()) { case (R.id.planTrip): System.out.println("PLANTRIP BUTTON"); try { util.planTripUtil(MainActivity.this); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } break; default: break; } } </code></pre> <p>Utils Activity</p> <pre><code> public void planTripUtil(Context context) throws IOException { boolean canGetStartCoord = GC.canGetCoordinates; boolean canGetEndCoord = GC.canGetCoordinates; if (canGetEndCoord &amp;&amp; canGetStartCoord) { Intent intent = new Intent(context, WebViewActivity.class); startActivity(intent); </code></pre> <p>}</p> <p>I'm getting this error whenever i click the button. I know the problem is with the startActivity(intent), it just gives my an IllegalStateException everytime. Any ideas why and how do i solve this?</p> <pre><code> 08-04 15:04:05.599: E/AndroidRuntime(23230): FATAL EXCEPTION: main 08-04 15:04:05.599: E/AndroidRuntime(23230): java.lang.IllegalStateException: Could not execute method of the activity 08-04 15:04:05.599: E/AndroidRuntime(23230): at android.view.View$1.onClick(View.java:3599) 08-04 15:04:05.599: E/AndroidRuntime(23230): at android.view.View.performClick(View.java:4204) 08-04 15:04:05.599: E/AndroidRuntime(23230): at android.view.View$PerformClick.run(View.java:17360) 08-04 15:04:05.599: E/AndroidRuntime(23230): at android.os.Handler.handleCallback(Handler.java:725) 08-04 15:04:05.599: E/AndroidRuntime(23230): at android.os.Handler.dispatchMessage(Handler.java:92) 08-04 15:04:05.599: E/AndroidRuntime(23230): at android.os.Looper.loop(Looper.java:137) 08-04 15:04:05.599: E/AndroidRuntime(23230): at android.app.ActivityThread.main(ActivityThread.java:5233) 08-04 15:04:05.599: E/AndroidRuntime(23230): at java.lang.reflect.Method.invokeNative(Native Method) 08-04 15:04:05.599: E/AndroidRuntime(23230): at java.lang.reflect.Method.invoke(Method.java:511) 08-04 15:04:05.599: E/AndroidRuntime(23230): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:799) 08-04 15:04:05.599: E/AndroidRuntime(23230): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:566) 08-04 15:04:05.599: E/AndroidRuntime(23230): at dalvik.system.NativeStart.main(Native Method) 08-04 15:04:05.599: E/AndroidRuntime(23230): Caused by: java.lang.reflect.InvocationTargetException 08-04 15:04:05.599: E/AndroidRuntime(23230): at java.lang.reflect.Method.invokeNative(Native Method) 08-04 15:04:05.599: E/AndroidRuntime(23230): at java.lang.reflect.Method.invoke(Method.java:511) 08-04 15:04:05.599: E/AndroidRuntime(23230): at android.view.View$1.onClick(View.java:3594) 08-04 15:04:05.599: E/AndroidRuntime(23230): ... 11 more 08-04 15:04:05.599: E/AndroidRuntime(23230): Caused by: java.lang.NullPointerException 08-04 15:04:05.599: E/AndroidRuntime(23230): at android.app.Activity.startActivityForResult(Activity.java:3381) 08-04 15:04:05.599: E/AndroidRuntime(23230): at android.app.Activity.startActivityForResult(Activity.java:3342) 08-04 15:04:05.599: E/AndroidRuntime(23230): at android.app.Activity.startActivity(Activity.java:3577) 08-04 15:04:05.599: E/AndroidRuntime(23230): at android.app.Activity.startActivity(Activity.java:3545) 08-04 15:04:05.599: E/AndroidRuntime(23230): at com.example.otpxmlgetter.Utils.planTripUtil(Utils.java:120) 08-04 15:04:05.599: E/AndroidRuntime(23230): at com.example.otpxmlgetter.MainActivity.buttonCalls(MainActivity.java:202) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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