简体   繁体   中英

Is it possible to trigger Android service from mobile browser?

I am interested in if it is possible to trigger android service from webpage. The main problem is to solve possibility to tiger printing of the device when user is on certain page.

I was investigation possibility of the Custom URL scheme that will trigger service of the android application.

So is it possible to trigger service form webpage? And should i use Custom URL scheme to do it ?

Web browsers send android.action.VIEW intent for every URL they open. If you define the service to have intent filter that will catch the URL, then it will be triggered. What you do in the intent receiver is completely upon you.

For Android, the preferred way is to catch HTTP URLs on your domain (possibly inside a specific path) so that it can show something even without the service being installed. However this will ask the user whether he want to open it with your service or the web browser (but they can select to always open it with your application in the future) so custom scheme is useful when you don't wont the user to be asked. IMO the most appropriate custom scheme is your application's ID ( com.example.application.android:some_data ) which is very unlikely to be used by anyone else.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM