Johannes Muenichsdorfer Johannes Muenichsdorfer - 1 year ago 94
Java Question

How to use the ShowcaseView library or something similar in a service?

As I already wrote in the title, I'm searching for a way to display the ShowcaseView Library in a service. The Service is displaying a floating widget like the facebook messenger chat head.`The problem is, that "MaterialShowcaseView.Builder(this)" is asking for an "" attribute.

// single example
new MaterialShowcaseView.Builder(this)
.setDismissText("GOT IT")
.setContentText("This is some amazing feature you should know about")
.setDelay(withDelay) // optional but starting animations immediately in onCreate can make them choppy
.singleUse(SHOWCASE_ID) // provide a unique ID used to ensure it is only shown once


Thanks for your help!

Answer Source

Update: I ended up not using the ShowcaseView Library in my Service, and implement another demo with simple TextViews myself.

This is how I do it now: I'm just showing some TextViews beside the buttons I want to introduce to the users. This is not like the ShowcaseView but it works perfectly for me.

Creating a TextView in a Floating Service: (I set the TextView in the XML File to "INVISIBLE" to and after it is initialized to "GONE")

LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);

exampleTextLayout = (LinearLayout) inflater.inflate(R.layout.exampleTextLayout, null);
exampleTextView= (TextView) exampleTextLayout.findViewById(;

WindowManager.LayoutParams textViewParam = new WindowManager.LayoutParams(
                WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
        textViewParam.gravity = Gravity.TOP | Gravity.START;

windowManager.addView(exampleTextLayout, textViewParam);

And than later when I want to show the Text I do this: (I skipped the animation part)

WindowManager.LayoutParams param_txt = (WindowManager.LayoutParams) layoutView.getLayoutParams();

param_txt.x = [xPosition of TextView]
param_txt.y = [yPosition of TextView]

if(layoutView.isAttachedToWindow()) {
      windowManager.updateViewLayout(exampleTextLayout, param_txt);

This is how it looks: (Text is German if you wonder)

enter image description here

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download