Should I leave the bluetooth reflection hack in production code?

前端 未结 1 1803
孤街浪徒
孤街浪徒 2021-01-31 10:35

I\'m working in a project where I need to connect via bluetooth to a printer. The printer manufacturer states that only android phones having SPP (Serial Port Profile) are going

相关标签:
1条回答
  • 2021-01-31 11:02

    Superb question. Basically you can use reflection all you want. Even i did something similar inorder to calculate the application launch times, got a method via reflection and its working like a charm from FroYo till Jelly Bean. The only word of caution you need to exercise is this,

    • Since it is not a public API, google can change it anytime without warning
    • If it changes, the system apps or HAL which uses it will be accordingly modified without any applications getting affected.

    Where will you need to be careful?

    Chances are the arguments of this method may get modified in the future.

    So you will need to check for this with each new OS release so that your application does not break. Otherwise you need not worry about using this hack. Many applications use such hacks when things arent exposed with the API.

    0 讨论(0)
提交回复
热议问题