Hiding permission intent in Android?

2019-07-17 21:30发布

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.

2条回答
三岁会撩人
2楼-- · 2019-07-17 22:27

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.

查看更多
你好瞎i
3楼-- · 2019-07-17 22:34

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

查看更多
登录 后发表回答