0

My Application is crashing when I try to start new Activity. Need Help!

LoginAysnc logins = new LoginAysnc((Context) con);
logins.execute(); 



class LoginAysnc extends AsyncTask<Void, Void, String> {

    public LoginAysnc(Context context){
        contexts = context;
    }

    @Override
    protected void onPostExecute(String s) {
        super.onPostExecute(s);
            startActivity(new Intent(contexts.getApplicationContext(),home.class));

    }
AndyN
  • 1,742
  • 1
  • 15
  • 30
aryan
  • 1
  • 1
  • 3
  • What you doing in AsyncTask? Are calling any Api?? Can you post your doInBackground() method as well. – Saritha G Feb 15 '16 at 11:25
  • am trying get employee details from website in background as JsonString – aryan Feb 16 '16 at 04:26
  • 02-16 10:04:36.449 86-86/? W/InputManagerService: Got RemoteException sending setActive(false) notification to pid 572 uid 10040 02-16 10:04:45.418 86-100/? W/ActivityManager: Activity destroy timeout for ActivityRecord{41187748 com.goodscab.android.goodscabserviceprovider/.MainActivity} 02-16 10:04:45.418 86-100/? W/ActivityManager: Activity destroy timeout for ActivityRecord{4128cf48 com.goodscab.android.goodscabserviceprovider/.home} – aryan Feb 16 '16 at 04:38

3 Answers3

1

Maybe you should call the method

@Override
protected String doInBackground() {
    // Your code to execute here
    return s;  // This is the String you get as a parameter in onPostExecute
}

That is the whole point of the AsyncTasks. Then your code in onPostExecute will get called. But I agree that you should post your LogCat to see what's wrong

Roger
  • 76
  • 1
  • 4
0

Simply pass the Context instead of the Application Context.

startActivity(new Intent(contexts,home.class));

And check if you declared home activity in the Manifest.

thedarkpassenger
  • 7,158
  • 3
  • 37
  • 61
0

start your activity like:

startActivity(new Intent(CurrentActivity.this,NewActivity.class));

Saritha G
  • 2,588
  • 1
  • 15
  • 27