开发者

How to detect launch of an app in Android from a background service or another app

开发者 https://www.devze.com 2022-12-21 15:05 出处:网络
I want to create an app or background service that just listens for the launch of a \'default\' app, say Contacts or the built-in Gmail app. If the contact app is clicked, I want to transfer control t

I want to create an app or background service that just listens for the launch of a 'default' app, say Contacts or the built-in Gmail app. If the contact app is clicked, I want to transfer control to my app temporarily开发者_如何学运维 (e.g. present a Yes/No popup to the user or increment an internal counter of my app ) and then redirect the user back to the app that was clicked. I want to do this only for a couple of 'well-known' built-in default apps, not any third party apps.

Is this possible? May be using some special intents?


Have you tried registering broadcast receivers for the intents that would launch those built-in apps? This might not work since that might confuse Android into thinking your app is a potential target for those intents (e.g. that it should be used to actually write and send the email in the case of a 'compose an email' intent), but it should be a good place to start.

0

精彩评论

暂无评论...
验证码 换一张
取 消