receiver enabled=false , problems after instantiation to set to listen

by Jiri » Wed, 12 Aug 2009 18:09:11 GMT


Sponsored Links
 Hello List,

in my manifest I set an custom object Dots that extends a 
BroadcastReceiver to receive a certain broadcast string.

<receiver
android:name=".model.Dots"
android:enabled="false">
<intent-filter >
<action android:name="org.dadata.demo.receiverTest" />
</intent-filter>
</receiver>

I dont want Android to instantiate the object for me hence the enable=false.

In the Activity a new Dots is created

Dots dots = new Dots()

How do i now make the Dots start listening to the broadcasting. I tried 
this, but it doesnt work and it also feels much to complicated..

ComponentName cName = new 
ComponentName("org.dadata.demo","org.dadata.demo.Dots");
PackageManager pm = this.getPackageManager();
pm.setComponentEnabledSetting(cName , 
PackageManager.COMPONENT_ENABLED_STATE_ENABLED , 
PackageManager.DONT_KILL_APP);

Is there a workable easy way to do this?

Thank you,

Jiri



--~--~---------~--~----~------------~-------~--~----~



receiver enabled=false , problems after instantiation to set to listen

by Jiri » Thu, 13 Aug 2009 15:48:39 GMT


 > If you don't want android instantiating a component, there is no reason
 > to declare it in a manifest.

Thank you for the clear answer.

And yes it should have been

 >ComponentName("org.dadata.demo",".model.Dots");

Jiri





--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


receiver enabled=false , problems after instantiation to set to listen

by Jiri » Thu, 13 Aug 2009 16:23:48 GMT


 One more question. In my Activity.onDraw method I have this:

Dots dotModel = new Dots();

IntentFilter iFilter = new IntentFilter();
iFilter.addAction("org.dadata.demo.ON_UPDATE");
this.registerReceiver(dotModel, iFilter);

Then later in a click handler I wrote this:

Intent intent = new Intent();
intent.setAction("org.dadata.demo.ON_UPDATE");
getApplicationContext().sendBroadcast(intent);

Is there some way to externalise the now hardcoded string:
"org.dadata.demo.ON_UPDATE" so i can access it from anywhere and 
reducing the risk of typed errors?

Jiri






--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. How to make ImageView fill vertically within RelativeLayout

I put an ImageView and a TextView within a RelativeLayout, and want
the ImageView to grow vertically with the line number of TextView. The
drawable of the ImageView is a png picture of vertical bar.

With the following layout, the ImageView does not fill the height of
the RelativeView. Instead, it alway keeps the original picture's
height.

Why does it not work as I expect?

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/
android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <ImageView android:id="@+id/iv"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:layout_alignParentLeft="true"
        android:src="@drawable/vbar"
        android:adjustViewBounds="false"
        android:scaleType="fitXY"/>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:singleLine="false"
        android:layout_toRightOf="@id/iv"
        android:layout_alignParentBottom="true" />
</RelativeLayout>
--~--~---------~--~----~------------~-------~--~----~

2. Android emu on Mac OS X 10.5.7

Hey,
      It's the first time that i run the android emulator on the mac. and
I'm pretty sure that i have configure it well.

so i write a program called AndroidDialer
here is the program

package com.google.android.AndroidDialer;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class AndroidDialer extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        final EditText numberInputed = (EditText)
findViewById(R.id.numberInputed);
        final Button callButton = (Button) findViewById(R.id.callButton);

        callButton.setOnClickListener(new Button.OnClickListener(){
            public void onClick(View v) {
                Intent callIntent = new Intent(Intent.ACTION_CALL,
Uri.parse("tel:" + numberInputed.getText().toString()));
                callIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                startActivity(callIntent);
            }
        });
    }
}


and when I lunch the emulator it show  something  that i have never meet
before.
"[2009-07-11 11:34:59 - Emulator] 2009-07-11 11:34:59.236 emulator[3585:10b]
Warning once: This application, or a library it uses, is using
NSQuickDrawView, which has been deprecated. Apps should cease use of
QuickDraw and move to Quartz.
"

so could anyone be kind enough to help me ?
thanks.

--~--~---------~--~----~------------~-------~--~----~

3. How can I use the hidden provider?

4. why would InputStreamReader returns null

5. ACCURACY_COARSE and ACCURACY_FINE

6. How to obtain bitmap from data in onPreviewFrame method of previewCallback and display on surface using canvas

7. Signing APK and "Conversion to Dalvik format failed with error 1"