NFC... TAG_DISCOVORED intent is only send via startActivity()

by z_z_z_z » Fri, 04 Feb 2011 05:16:25 GMT


Sponsored Links
 Hello,

I have a device that is constantly sending NFC tags each of it has
only one characte "a" as rawdata , this is not the interesting part.
The problem is that I'm writing a Service that have a
BroadcastReceiver that is listening for the tag_discovered intent. The
idea is when the onReceive() method is called in the BR it will call
some methods in the service. So I've take a looked at the source of
NFCService.java and there the intent is fired with startActivity(). So
I cant use broadcast receiver. Is there any special reason to be made
like that, with startActivity() but not with sendBroadcast()? So in my
case I'm forced to use activity to catch the intent thet in it's
onCreate() it calls my broadcaste receiver via sendBroadcast() and
then at the end of the onCreate() it calls finish(). This solution is
very ugly one, because if I have some other application's Activity
running ontop it's onPause() method is colled.... terrible...

So am I missing something about the nfc apps in android and what are
your suggestions about my problem?

-- 



Other Threads

1. Context Menu pops-up twice

Hi,

I'm trying to make a context menu for a little notes application, and
it has some weird behaviour. My notes are categorized in.. well
categories. I'm using a ExpandableListView to show the categories
(groups) and notes (children). I have registered for context menu, and
what happens is the following:

 * When I click and hold a category, my context menu pops up which has
one option "delete".
 * When I click delete, the category gets deleted and the context menu
disappears, but then a new context menu pops up which has also
"delete" in it, but it isnt clickable. The only way to close it is to
use the "back" button.

I don't get why that second context menu pops up and how I can get rid
of it, I hope somebody here can help me.

Here is my code, if additional code pieces please tell me. :)

        public void onCreateContextMenu(ContextMenu menu, View v,
                        ContextMenuInfo menuInfo) {
                super.onCreateContextMenu(menu, v, menuInfo);

                ExpandableListView.ExpandableListContextMenuInfo info =
                        (ExpandableListView.ExpandableListContextMenuInfo) 
menuInfo;

                int type =
ExpandableListView.getPackedPositionType(info.packedPosition);

                // Context menu for categories
                if(type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
                        menu.addSubMenu(0, CONTEXT_DELETE_CAT, 0, 
R.string.delete);

                // Context menu for notes
                } else if(type == 
ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
                        menu.addSubMenu(0, CONTEXT_DELETE_NOTE, 0, 
R.string.delete);
                }
        }

        public boolean onContextItemSelected(MenuItem item) {

                ExpandableListContextMenuInfo info =
                        (ExpandableListContextMenuInfo) item.getMenuInfo();

                switch(item.getItemId()) {
                case CONTEXT_DELETE_CAT:
                        long categoryId = info.id;
                        db.categories.deleteWithNotes(categoryId);
                        mAdapter.notifyDataSetChanged();
                        fillView();
                        return true;
                case CONTEXT_DELETE_NOTE:
                        long noteId = info.id;
                        db.notes.delete(noteId);
                        fillView();
                        getExpandableListView().expandGroup(mOpenedCategory);
                        return true;
                default:
                        return super.onContextItemSelected(item);
                }
        }

-- 

2. DDMS, Eclipse: Can't access 'Data' - Directory on external device

Dear all,

I'm developping an android application with Eclipse.
Whe I run the emulator I can access the applications database by DDMS
and the 'Data' - directoy.

But when I run the application (every application) on my external
device, I can't open the 'data'-directory. If I try to push data on
the external device (by DDMS) there is an error message:
"Failed to push <filename> on <deviceID>: Permission denied

The debugging mode is activated and I can run/ debugg the application
normaly on this device.

Do you know this problem?

Best regards,
Thomas

-- 

3. timeout on wakelock causes "WakeLock under-locked" error

4. Managed Query Won't Return Name Of Contact Who Owns Device

5. How to access modem in a native C libs

6. build android sdk from git on ubuntu 10.04 fail

7. How to find if the device is connected via USB.