Question

Is there any ability to detect if context is from activity or adapter?

It's essential to detect if we can do

(Activity(context)).startActivityForResult(..) ...
Was it helpful?

Solution

You can try

if(context instanceof Activity)
     (Activity(context)).startActivityForResult(..);

This should work.

OTHER TIPS

Your constructor for adapter

public YourAdapter(Context context) {
    this.context = context;
}

When you call it in activity

 adapter = new YourAdapter(YourActivity.this);

So you have context in your adapter.

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