tags:

views:

57

answers:

1

How can I write a Broadcast Receiver that will be invoked when user clicks on any application icon?

I tried by writing:

<receiver android:name = "myreceiver"> 
    <intent-filter> 
        <action android:name = "android.intent.action.MAIN"> 
    </intent-filter> 
</receiver> 

But it is not called.

I tried, by using Packagemanager I will get ApplicationInfo. From that I can know all the application starting activity name and package names. I thought I can use them to registerReceiver and my receiver will listen by its launching activity and package name. But I strucked. I am unable to do that. I think I lost the way.

What can I do to solve this problem?

+1  A: 

I don't think this is possible, there is just too much room for abuse. What are you trying to do that you would need to be notified anytime someone launched an application?

CaseyB
I actually was also looking for similar functionality to log user activity (apps opening, mainly, not keypress/browser activity, etc)
Adam
i would like to keep lock to application.when ever user tries to start the application i.e clicks on application icon my receiver has to leason to it and a dialog box will opened if user gives correct details then application will unlocked and application will start..now tell me am i in right way to achieve my task..please guide me..thanks in advance..
What I'm telling you is that I don't think there is a way to achieve what you want. You can (of course) tell when apps that you have written, but I don't think the OS will allow people to hook into the launch of all apps.
CaseyB
if it is our application we can register a broadcastreceiver with our own action and we can achive it right?thanks for your clarification caseyB..any way it is very bad news for me..