Hiding permission intent in Android?

落花浮王杯 提交于 2019-12-13 16:06:46

问题


As we know, Android OS has some restrictions to operate device hardwares programmetically, like it shows intent to user which requires YES for return true to the specific intent, i-e:

Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableBtIntent, 1);

I want to hide this intent from user, and want to return true, as if user click YES, is there any way to code like this ?

I am not asking about turn ON bluetooth without permission, like( myBlueToothAdapter.enable() works) I have to hide another intent which works same as this one..

Hope someone can guide me to the proper way. Thanks in advance.


回答1:


The security mechanisms in place for Android would inherently forbid this.




回答2:


I am not quite understand you are asking. It seems that you don't want to use the built-in Intent that requests the user to turn on the bluetooth radio. If this is the case, you are saying you want to have your own intent (activity) that ask the user to turn on/off bluetooth? You can use BluetoothAdapter.enable() in your activity to do this. OR you can use that API to turn on bluetooth without asking the user.



来源:https://stackoverflow.com/questions/6938237/hiding-permission-intent-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!