Question

I have an adapter class :

public class AdapterAllAddress extends BaseExpandableListAdapter {
private Context context;
    public AdapterAllAddress(Context context,
            ArrayList<AllAddressesGroup> groups) {
        // TODO Auto-generated constructor stub
        this.context = context;
    }
}

I want to call startActivityForResult when a button click , I know I can call startActivity like this:

context.startActivity() 

but i am looking for activity with results, how please ?

Was it helpful?

Solution

yourButton.setOnClickListener(new OnClickListener() {

    @Override
    public void onClick(View v) {
    // TODO Auto-generated method stub
        Intent intent = new Intent(context, YourNewActivity.class);
        ((Activity) context).startActivityForResult(intent, resultCode);
    }
});

OTHER TIPS

I just wanted to point a detail which i faced in my case E/ActivityThread(31584): Performing stop of activity that is not resumed: {com.example.test/activities.MainActivity} most probably you are passing getApplicationContext() to the adapter's constructor . In order to avoid this you must provide "CallingActivity.this" to the adapter's constructor as the context object , keep this in mind .

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top