DEV Community

Jerald Jacob
Jerald Jacob

Posted on

How can I access a Non-static method In a library

Hi, I'm new to android. Now I have used a library to implement ripple effect into my application.
This is the scenario.
1) I'm using the button image and its background ripple effect through an API from the server-side, and I'm keeping the response at the time of application login, into SharedPreferences.
2) I'm using the BroadcastReceiver to implement the button effect.
3) The button is represented as an image and its background ripple effect.
(The library I used for this implementation is
4) The library provides the ripple color in the form of TypedArray
(hear is the code section of the implementation)

        final TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.RippleBackground);
    rippleColor=typedArray.getColor(R.styleable.RippleBackground_rb_color, getResources().getColor(R.color.rippleColor));
    rippleStrokeWidth=typedArray.getDimension(R.styleable.RippleBackground_rb_strokeWidth, getResources().getDimension(R.dimen.rippleStrokeWidth));
Enter fullscreen mode Exit fullscreen mode

in this code rippleColor=typedArray.getColor(R.styleable.RippleBackground_rb_color, getResources().getColor(R.color.rippleColor));
That is my problem part.

Already I mention that I'm using the SharedPreferences to keep the response.
how can I parse the response through the library and get the ripple color which I provide through my response?

hear is my code

Enter fullscreen mode Exit fullscreen mode

my BroadcastReceiverClass is not a static class (Because it receives the auth response through the Intent).

Now I'm trying to access Non-static method 'getRadarColor()' cannot be referenced from a static context. How can I fix this problem?
I can't create an instance of the class at that library (Because it BroadcastReceiverClass ** extends FrameLayout*) and the contractor has different parameters Like **Context context, AttributeSet attrs, int defStyle*

If anyone knows about this problem please share your suggestions.
Moreover, I think it's not a big thing but unfortunately, it consumes me more than a day.

Discussion (0)