Note that there are some explanatory texts on larger screens.

plurals
  1. POCould not execute method of the activity error in android
    primarykey
    data
    text
    <p>Am getting this error "Could not execute method of the activity" ... can some one help why this is happening ?</p> <pre><code>06-17 15:47:54.562: E/AndroidRuntime(910): FATAL EXCEPTION: main 06-17 15:47:54.562: E/AndroidRuntime(910): java.lang.IllegalStateException: Could not execute method of the activity 06-17 15:47:54.562: E/AndroidRuntime(910): at android.view.View$1.onClick(View.java:3591) 06-17 15:47:54.562: E/AndroidRuntime(910): at android.view.View.performClick(View.java:4084) 06-17 15:47:54.562: E/AndroidRuntime(910): at android.view.View$PerformClick.run(View.java:16966) 06-17 15:47:54.562: E/AndroidRuntime(910): at android.os.Handler.handleCallback(Handler.java:615) 06-17 15:47:54.562: E/AndroidRuntime(910): at android.os.Handler.dispatchMessage(Handler.java:92) 06-17 15:47:54.562: E/AndroidRuntime(910): at android.os.Looper.loop(Looper.java:137) 06-17 15:47:54.562: E/AndroidRuntime(910): at android.app.ActivityThread.main(ActivityThread.java:4745) 06-17 15:47:54.562: E/AndroidRuntime(910): at java.lang.reflect.Method.invokeNative(Native Method) 06-17 15:47:54.562: E/AndroidRuntime(910): at java.lang.reflect.Method.invoke(Method.java:511) 06-17 15:47:54.562: E/AndroidRuntime(910): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) 06-17 15:47:54.562: E/AndroidRuntime(910): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 06-17 15:47:54.562: E/AndroidRuntime(910): at dalvik.system.NativeStart.main(Native Method) 06-17 15:47:54.562: E/AndroidRuntime(910): Caused by: java.lang.reflect.InvocationTargetException 06-17 15:47:54.562: E/AndroidRuntime(910): at java.lang.reflect.Method.invokeNative(Native Method) 06-17 15:47:54.562: E/AndroidRuntime(910): at java.lang.reflect.Method.invoke(Method.java:511) 06-17 15:47:54.562: E/AndroidRuntime(910): at android.view.View$1.onClick(View.java:3586) 06-17 15:47:54.562: E/AndroidRuntime(910): ... 11 more 06-17 15:47:54.562: E/AndroidRuntime(910): Caused by: android.os.NetworkOnMainThreadException 06-17 15:47:54.562: E/AndroidRuntime(910): at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1117) 06-17 15:47:54.562: E/AndroidRuntime(910): at java.net.InetAddress.lookupHostByName(InetAddress.java:385) 06-17 15:47:54.562: E/AndroidRuntime(910): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236) 06-17 15:47:54.562: E/AndroidRuntime(910): at java.net.InetAddress.getAllByName(InetAddress.java:214) 06-17 15:47:54.562: E/AndroidRuntime(910): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:137) 06-17 15:47:54.562: E/AndroidRuntime(910): at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164) 06-17 15:47:54.562: E/AndroidRuntime(910): at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119 ) 06-17 15:47:54.562: E/AndroidRuntime(910): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360) 06-17 15:47:54.562: E/AndroidRuntime(910): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555) 06-17 15:47:54.562: E/AndroidRuntime(910): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487) 06-17 15:47:54.562: E/AndroidRuntime(910): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465) 06-17 15:47:54.562: E/AndroidRuntime(910): at com.test.readurl.JSONParser.makeHttpRequest(JSONParser.java:62) 06-17 15:47:54.562: E/AndroidRuntime(910): at com.test.readurl.MainActivity.button1_onClick(MainActivity.java:40) 06-17 15:47:54.562: E/AndroidRuntime(910): ... 14 more </code></pre> <p>while trying to execute...</p> <pre><code>package com.test.readurl; import java.util.ArrayList; import java.util.List; import org.apache.http.NameValuePair; import org.apache.http.message.BasicNameValuePair; import org.json.JSONException; import org.json.JSONObject; import android.os.Bundle; import android.app.Activity; import android.util.Log; import android.view.Menu; import android.view.View; import android.widget.Toast; public class MainActivity extends Activity { private static final String url_detials = "http://foefinder.com/api/details.php"; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } public void button1_onClick(View view){ //Toast.makeText(getApplicationContext(), "Hello Test", Toast.LENGTH_LONG).show(); // JSON parser class JSONParser jsonParser = new JSONParser(); // Building Parameters List&lt;NameValuePair&gt; params = new ArrayList&lt;NameValuePair&gt;(); String pid = null; params.add(new BasicNameValuePair("pid", pid)); // getting product details by making HTTP request // Note that product details url will use GET request JSONObject json = jsonParser.makeHttpRequest( url_detials, "GET", params); // check your log for json response Log.d("Single Product Details", json.toString()); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_main, menu); return true; } } </code></pre> <p>Am trying to read a URL from this app on a button click... but not able to do so... can some one help me with this ?</p>
    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.
    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