Bean Bird in Circle


This activity shows UIs in the Quick Circle window when it is launched while the cover is closed.

Create and Show a Template

A Quick Circle layout with no sub-area is created.

template = new QCircleTemplate(this, TemplateType.CIRCLE_EMPTY);


setContentView() shows the created template.



Add a Title

mTitle is a QCircleTitle instance and it is added to the QCircle template.

mTitle = new QCircleTitle(this, "Bean Bird In Circle");


Add a Back Button

mBackButton is a QCircleBackButton instance and added to the template.

setTheme() decides the background color of the mBackButton. The default is ButtonTheme.LIGHT.

mBackButton = new QCircleBackButton(this);


Connect to Full Screen Activity

Intent shows a webpage of the specified URL. Intent is sent when the cover is opened.

String url = "";
Intent intent = new Intent(Intent.ACTION_VIEW);


Since registeredIntentReceiver() is used, unregisterReceiver() is used.

protected void onDestroy() {


Activate Number Badge

numberIntent is an intent for the number badge. activateNumberBadge() returns a created intent for the number badge with a specified count. Here, a number badge with one is created.

Context broadcast the intent to actually show the number badge on the icon.

final Intent numberIntent  = QCircleFeature.activateNumberBadge(activity, 1);


Set background

mypic is a drawable for the circle background. setBackgroundDrawable() sets a drawable object as the background.

mypic = getResources().getDrawable(R.drawable.background1);


Add Button

btn switches a background drawable when it is clicked. notiBtn increases the number on the number badge when it is clicked.

Button btn = new Button(mContext); ①

LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
params.topMargin = QCircleFeature.getRelativePixelValue(this,300);
btn.setLayoutParams(params); ② 

btn.setOnClickListener(new OnClickListener() { ③

public void onClick(View v) {
if(mSwitched == false)
       mSwitched = true;
       mSwitched = false;

Button notiBtn = new Button(mContext);  ④
notiBtn.setText("Number Badge");
params = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.ALIGN_LEFT, btn.getId());
params.topMargin = QCircleFeature.getRelativePixelValue(this,270);
params.leftMargin = QCircleFeature.getRelativePixelValue(this,50);

notiBtn.setLayoutParams(params);  ⑤
notiBtn.setOnClickListener(new OnClickListener() { 
   int count = 1;
   public void onClick(View v) {
        QCircleFeature.setNumberBadge(activity, numberIntent, count);  ⑥
        mContext.sendBroadcast(numberIntent); ⑦

① Creates a button instance.

② Sets layout parameters of btn. getRelativePixelValue() method gets a pixel value appropriate for the current running model.

③ Sets onClickListener to switch a background drawable when btn is clicked.

④ Creates a button instance.

⑤ Sets layout parameters of notiBtn.

⑥ Changes the number in the number badge to the count; the count is increased when notiBtn is clicked.

⑦ The activity broadcasts numberIntent to change.