General_Twyckenham
General_Twyckenham

Reputation: 2261

Calling an activity from a fragment - activity doesn't run

New to Android so bear with me.

I have a fragment (DirectionsFragment) that calls an Activity to get some data from Yelp (YelpActivity).

When I run the YelpActivity itself, without calling it from DirectionsFragment, it runs succesfully (displays the received information, prints out appropriate log messages, etc.).

However, when I create YelpActivity from the fragment, nothing happens - no log messages, no retrieved information. Here's how I create the YelpActivity

@Override
    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        YelpActivity ya = new YelpActivity();
    }

Thanks

Upvotes: 0

Views: 44

Answers (1)

Raghunandan
Raghunandan

Reputation: 133560

Activity is started by startActivtiy(intent). But you have

YelpActivity ya = new YelpActivity();

Should not create an instance of Activity class.

Use

startActivity(new Intent(getActivtiy(),YealpActivtiy.class);

Make sure you have declared the activity in manifest file

Upvotes: 1

Related Questions