Note that there are some explanatory texts on larger screens.

plurals
  1. POCalling the second activity from AsyncTask of the first in Android
    primarykey
    data
    text
    <p>I've 2 layouts: MainActivity.xml, MenuActivity.xml. I want to load the MenuActivity from AsyncTask of the 1-st. Here's the UPDATED code:</p> <pre><code>class InternetCheck extends AsyncTask&lt;Activity, Void, Boolean&gt; { public Activity act=new Activity(); protected Boolean doInBackground(Activity... activities) { boolean status=false; act=activities[0]; String rurl=act.getString(R.string.url_test); try { URL url = new URL(rurl); HttpURLConnection urlc = (HttpURLConnection) url.openConnection(); urlc.setRequestProperty("Connection", "close"); urlc.setConnectTimeout(1000 * 20); // mTimeout is in seconds urlc.connect(); if (urlc.getResponseCode() == 200) { status=true; } } catch (MalformedURLException e1) { status=false; } catch (IOException e) { status=false; } return status; } protected void onPostExecute(Boolean result) { if (result==false) { MainActivity mActivity = (MainActivity) act; mActivity.ShowNoConnectionButton(); } else { Intent intent = new Intent(act, MenuActivity.class); act.startActivity(intent); //setContentView(R.layout.menu_activity); }; } } </code></pre> <p>If result is false we show button from UI class, and if it's true, we must load the second activity. For startActivity(intent) I get error: the method is undefined for type InternetCheck. Also is it all right with Intent parameters and calling UI method ShowNoConnectionButton from AsyncTask? It's rather difficult to understand what we must put in Intent parameters and how to get these.</p> <p>BUT IT STOPS THE APP WITH ERROR.</p> <p>The second screen class:</p> <pre><code>public class MenuActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.menu_activity); } } </code></pre>
    singulars
    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