Handling an Intent without an Activity UI

by mafro » Tue, 09 Jun 2009 18:35:03 GMT

Sponsored Links
 Hey list,

I've searched for a few hours for a solution to this, so hopefully
this isn't a repost :s

I'm setting a shortcut on the Home screen which raises an Intent to my
application - the problem is that I don't want to show my app, just
run a little code and display a Toast notification.

This must be possible - I just can't work out how.. Once I'm handling
the shortcut Intent in onCreate() the UI has initialised and I get a
little screen flicker if I then run my code and finish().

Thanks for any input!


Handling an Intent without an Activity UI

by mafro » Wed, 10 Jun 2009 17:31:24 GMT

 I'm thinking I might need to write a service to handle my shortcut's
Intent. The main application could then raise a similar Intent to the
service to provide the same functionality whilst in the application.

Comments anyone?


Sponsored Links

Handling an Intent without an Activity UI

by Mark Murphy » Wed, 10 Jun 2009 20:10:06 GMT


I do not know if you can create home screen shortcuts that send
broadcast Intents. If you can, then register a BroadcastReceiver in your
manifest to catch some custom action, and set up your shortcut to send a
broadcast Intent with that action. If what you need to do takes only a
few seconds, you can do the work within the BroadcastReceiver;
otherwise, have the receiver call startService() to trigger some
IntentService to do the real work.

This seems terribly complex, compared to just giving the user a real
activity to work with, but, hey, it's your app... :-)

Mark Murphy (a Commons Guy)
 http://commonsware.com  |  http://twitter.com/commonsguy 

Warescription: Three Android Books, Plus Updates, $35/Year


Handling an Intent without an Activity UI

by mafro » Wed, 10 Jun 2009 21:02:47 GMT

 You're right it does sound terribly complex. Ill report back on my
findings for anyone else who has a similar problem.

Thanks for your input, Mark.


Other Threads

1. Serious Problem with AudioRecord on NexusOne

Hey. I'm running AudioRecord to capture sound. It runs inside a
service. But, after the initial run after installing the app (in which
I've never seen this bug occur), the sound goes blank about 20% of the
time after 0-20 seconds of running. Audio data STILL gets captured
from the hardware, however, it is completely silent. If you examine
the console you will see that AudioHardwareQSD enters standby mode,
or  you can use the volume meter and you will see that it goes dead to
assist in seeing this bug.

05-30 11:49:37.639: DEBUG/dalvikvm(697): GC_FOR_MALLOC freed 8417
objects / 326880 bytes in 62ms
05-30 11:49:37.639: INFO/AudioHardwareQSD(59): do input routing device
05-30 11:49:37.639: INFO/AudioHardwareQSD(59): Routing audio to
05-30 11:49:37.650: WARN/AudioFlinger(59): RecordThread: buffer
05-30 11:49:37.780: DEBUG/AudioHardwareQSD(59): Switching audio device
05-30 11:49:37.780: DEBUG/AudioHardwareQSD(59): Speakerphone
05-30 11:49:37.871: INFO/AudioHardwareQSD(59): AudioHardware PCM
record is going to standby.

This bug does not occur on any other phone than the nexus. Someone
told me that AudioHardwareQSD is
related to the snapdragon audioprocessor for the second microphone.

Quickly view the relevant source in pastebin: http://pastebin.com/3xVEjiLE

The full source is here:

Which is part this bug: http://code.google.com/p/android/issues/detail?id=8732



2. Any other way to point to R.java?

I would like to remove the dependency to point to "packagename".R
since I'm trying to merge free and paid apps into one.  The mayor
problem is the namespace.

I'm able to get Context.getPackageName()  but how can I convert that
string to be accessible... i.e. Context.getPackageName().R?



3. Asynchronous Http Request

4. Clear defaults programmatically

5. Google Feedback fo Android

6. nullPointerException with custom ArrayAdapter

7. nullPointerException with custom ArrayAdapter