Auto attendant

by sthustfo » Wed, 17 Dec 2008 01:39:49 GMT

Sponsored Links

With the current state of the API, is it possible to write an auto-attendant
application that answers/forwards/rejects a call depending on certain
criteria? AFAIK (SDK1.0 rc1), PhoneStateListener can only be used to get a
hook into the incoming call, but there is know way to change the state of
the call itself. Has anything changed with rc2?

Further, is it possible to suppress the default phonecallapp when the
incoming call comes? Currently I see that any app that is written to listen
to IC call, is put to the background till the default phoneapp activity is



Other Threads

1. How to style my own styleable with a style? (Custom view class with custom attribute)

If you are using attrs.getAttributeResourceValue(), then you are not using
the style/theming system at all.  That is, there was no purpose to defining
a <declare-styleable> an <attr> at all, that function is just retrieving a
raw value from a resource for a given name.  (This is also why the "" URI doesn't matter -- you
have declared it as a namespace in your XML, and you have retrieved the
attribute in that namespace in your Java code, and that is all that is
happening.  You just made up a namespace and used it.)

You can find a complete example if declaring styleables and themes in API
demos.  Basically you declare a styleable like this (there is no "id" field
that is used):

<declare-styleable name="LabelView">
  <attr name="text" format="string"/>
  <attr name="textColor" format="color"/>
  <attr name="textSize" format="dimension"/>

Then use it in a layout like this:

<LinearLayout xmlns:android=""






            app:text="Green" app:textColor="#ffffffff" />


Note that the URI of xmlns:app is very important, this is the namespace for
android resources (the first part) in your package (the second part).

Finally to retrieve the resources, you do this:

    public LabelView(Context context, AttributeSet attrs) {
        super(context, attrs);

        TypedArray a = context.obtainStyledAttributes(attrs,


        CharSequence s = a.getString(R.styleable.LabelView_text);
        if (s != null) {

        // Retrieve the color(s) to be used for this view and apply them.

        // Note, if you only care about supporting a single color, that you
        // can instead call a.getColor() and pass that to setTextColor().
        setTextColor(a.getColor(R.styleable.LabelView_textColor, 0xFF000000));

        int textSize =
a.getDimensionPixelOffset(R.styleable.LabelView_textSize, 0);
        if (textSize > 0) {


The use of obtainedStyledAttributes() is very important, as that is the key
function that extracts the attributes you have declared in your styleable,
filling them in from the current AttributeSet or style or theme as

With all of that together, you can now define your theme, assigning values
to your own custom attributes that will be seen in your custom view.

On Wed, Jul 8, 2009 at 8:02 AM, <

Dianne Hackborn
Android framework engineer

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.


2. How to style my own styleable with a style? (Custom view class with custom attribute)


I'm creating my own View class, and defining custom xml attributes
with a attrs.xml. As long as I provide each attribute manually, there
is no problem, but

<?xml version="1.0" encoding="utf-8"?>
        <declare-styleable id="my.package.CustomizedButtonView"
                <attr name="borderDrawable" format="reference|color"/>

To be honest, I don't understand the proper use of the attributes "id"
and "name" in the above code, but somehow it works. I can now
reference the borderDrawable-Attribute from a layout xml file:

<?xml version="1.0" encoding="utf-8"?>

                                android:text="This is my text"

My class CustomizedButtonView now reads the attribute like this:
        public CustomizedButtonView(Context context, AttributeSet attrs) {
                super(context, attrs);
                int borderDrawableId = attrs.getAttributeResourceValue(
                                "borderDrawable", -1);

Until now, everything works fine. Many of my CustomizedButtonView will
have the same borderDrawable, but not all of them, so I want to define
a style. My styles.xml reads like this:

<style name="customStyle1">
                        name="android:text">Default text</item>

And the layout like that:

<?xml version="1.0" encoding="utf-8"?>


The android:text is properly set in my instance, but the
borderDrawable is not. I guess this has something to do with
namespaces, because inside the styles.xml, the
name="mypack:borderDrawable" is not handled by the XML parser's
namespace facility, because its inside an attribute value. So "mypack"
is in no way connected to "
matter" and adding it via xmlns:mypack... to the stylefile would not
help, I guess. In the same file, "android:text" is somehow recognized,
even though "android" is AFAIK only a ns-defintion for "http://", which is also not declared in
that file.

So what is the proper way to set a custom attribute in a style?

3. YUV to RGB cpnversion


5. Launch another app through Android Application.

6. using appendChild and replaceChild

7. is it possible to get realtime gps values while not in a mapview?