Chirag Bhardwaj
Chirag Bhardwaj

Reputation: 5

class returns an empty page when pressed back button

I called an intent from the class but on pressing back key it gives a blank screen. i want it to return to the previous list activity this class had been called from. my class is

package com.chirag.ipuconnect;

    import android.app.Activity;
    import android.content.Intent;
    import android.os.Bundle;

    public class GTBIT extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        String namaste="http://www.gtbit.org/";
        Intent dex=new Intent(GTBIT.this,MainActivity.class);
        dex.putExtra("url", namaste);
        startActivity(dex);

    }
}

Any help will be appreciated.

Upvotes: 0

Views: 657

Answers (3)

Addicted Manish
Addicted Manish

Reputation: 189

public void onBackPressed() {

//your code is here

}

Upvotes: 0

Heinrisch
Heinrisch

Reputation: 5935

Put a finish() after startActivity(dex).

Upvotes: 0

Opiatefuchs
Opiatefuchs

Reputation: 9870

You need to set the content in this Activity

 setContentView(R.layout.your_layout);

Or what You want to do with this Activity shown above? Is there a reason why You haven´t done this?

Upvotes: 2

Related Questions