如何在我的Android应用程序中关闭物理按钮的声音点击(声音效果)?(How to turn off physical button's sound click (sound effects) in my Android app?)
我正在开发一个Android应用,允许用户在设备上休息他的手,并且我想禁用物理按钮,这样用户就不会因不需要的点击而感到恼火。
我已经禁用后面的 , 菜单和搜索按钮与以下内容:
@Override public void onBackPressed() {} @Override public boolean onPrepareOptionsMenu(Menu menu) {return false;} @Override public boolean onSearchRequested() {return false;}而且我已经了解到,禁用Home键是不被支持和/或不被建议的(尽管我希望它)。
好吧,现在我无法弄清楚如何禁用我禁用的按键的点击声音,它们什么都不做,只是保持滴答状态,有没有办法关掉它?
我只想将它静音为我的应用程序。 如果不可能,我想知道有关以编程方式更改系统设置的替代方法,以便在关闭或焦点更改时对其进行恢复。
I'm developing an Android app where the user is allowed to rest his hand on the device, and I want to disable physical buttons so the user don't get annoyed by unwanted clicks.
I've disabled the back, menu and search buttons with the following:
@Override public void onBackPressed() {} @Override public boolean onPrepareOptionsMenu(Menu menu) {return false;} @Override public boolean onSearchRequested() {return false;}And I've learned that disabling the home key is unsupported and/or not adviced (although I'd like it to).
Ok, now I couldn't figure out how to disable the clicking sound for the keys I've disabled, they do nothing but keep ticking, is there a way to turn it off?
I'd like to mute it for my app only. If not possible, I'd like to know about alternatives that change system settings programmatically, to restore it latter on closing or on focus changing.
原文:https://stackoverflow.com/questions/10757942
最满意答案
我建议使用
requests
而不是urllib
,并使用json()
来处理响应:import json import hashlib import requests token = hashlib.sha1() token.update("calvinrock0406@gmail.comheaven3610255k592k2di4u9uok3e8u9pkfepjfoc809kfutv5z".encode('utf-8')) token_dig = token.hexdigest() response = requests.get("https://www.mediafire.com/api/user/get_session_token.php?application_id=36102&signature=" + token_dig + "&email=calvinrock0406@gmail.com&password=heaven&token_version=2&response_format=json") json_response = response.json() print json_response["response"]["session_token"]
I would recommend using
requests
instead ofurllib
, and usejson()
to work with the response:import json import hashlib import requests token = hashlib.sha1() token.update("calvinrock0406@gmail.comheaven3610255k592k2di4u9uok3e8u9pkfepjfoc809kfutv5z".encode('utf-8')) token_dig = token.hexdigest() response = requests.get("https://www.mediafire.com/api/user/get_session_token.php?application_id=36102&signature=" + token_dig + "&email=calvinrock0406@gmail.com&password=heaven&token_version=2&response_format=json") json_response = response.json() print json_response["response"]["session_token"]
相关问答
更多-
我建议使用requests而不是urllib ,并使用json()来处理响应: import json import hashlib import requests token = hashlib.sha1() token.update("calvinrock0406@gmail.comheaven3610255k592k2di4u9uok3e8u9pkfepjfoc809kfutv5z".encode('utf-8')) token_dig = token.hexdigest() response = ...
-
1)加载文件并解析json: json_data = json.load(open("filename.json")) 2)使用list comprehension获取所有用户id。 user_id_list = [x.get("user_id") for x in json_data] 1) Load the file and parse the json: json_data = json.load(open("filename.json")) 2) Use list comprehension ...
-
最后使用正则表达式操作 - re package从响应中提取所需的数据。 似乎这是从javascript响应中提取json数据的唯一方法。 衷心感谢Prashant Puri和Barmar对他们的快速和极大的帮助。 Finally extracted the required data from the response using Regular expression operations - re package. Seems like this is the only way to extract j ...
-
它应该是data.Results[i].UnitPrice和data.Results[i].UnitPrice 。 data是一个对象,Results(数组)是该对象的一个属性。 所以data.Results将为您提供数组本身。 It should be data.Results.length and data.Results[i].UnitPrice. data is an object, and Results (the array) is a property of that object. So d ...
-
看起来你在'contentsOfDictionary'中有一个字典,其中键是“1”,“2”,......并且值是包含姓名/电话号码的字典。 所以你只需要遍历所有值: NSMutableArray *studentDictionaries = [[NSMutableArray alloc] init]; for (NSDictionary *studentDictionary in contentOfDictionary.allValues) { [studentDictionaries addObj ...
-
要从响应对象中获取文本字符串,可以使用json_resp.text 。 然后,您可以使用json库将其转换为dict ,然后提取所需的字段: json_resp = requests.post(...) ## Your post request, as written above node = json.loads(json_resp.text) face_token = node['faces'][0]['face_token'] 以下是完整的代码(使用上面的代码片段): import request ...
-
首先,您需要以“a”模式打开文件,否则后续写入将覆盖所有内容 import requests import json url = 'https://api.github.com/users' token = "my_token" headers = {'Authorization': 'token %s' % token} outfile = open('users.json', 'a') while True: r = requests.get(url, headers=headers) ...
-
您应该返回$Video或任何其他变量或数组,而不是函数response() 编辑 尝试return json_encode($Video); You should return $Video or any other variable or array, not a function response() EDIT try to just return json_encode($Video);
-
您正在迭代“注释”,这会导致三个对象: data , paging和summary 。 你想要的只是paging ,但你的第一个for循环要求你通过所有其他的。 因此,当它从data开始时,您正在尝试调用data['paging'] ,但这不起作用,因为data的值是列表而不是字典。 您想立即访问paging : print data['comments']['paging']['next'] You're iterating through "comments" which results in thr ...
-
不用担心我想出了能够解决所有问题的代码: import facebook import requests import json import urllib import urllib2 #def some_action(post): #print posts['data'] # print(post['created_time']) access_token = 'ENTER ACCESS TOKEN' url = 'https://graph.facebook.com/v2.4/ENT ...