android - 二维码 - 如何?
问题描述
我想隐藏 QR CODE 的结果...例如: ?re=123456789012&rr= 我只想显示 123456789012 并隐藏 ?re= 和 &rr 我正在阅读,人们说使用拆分方法,对吗?
protected void onActivityResult(int requestCode,int resultCode,Intent data){
IntentResult result = IntentIntegrator.parseActivityResult(requestCode,resultCode,data);
if(result != null){
if(result.getContents()==null){
Toast.makeText(this,"cancelled", Toast.LENGTH_LONG).show();
}
else{
resultado.setText(result.getContents());
}
}
else {
super.onActivityResult(requestCode,resultCode,data);
}
}
解决方案
尝试使用子字符串函数:-
function
:-
private String getQR(String content)
{
return content.substring(4,15);
}
function implementation
:-
if(result.getContents()==null){
Toast.makeText(this,"cancelled", Toast.LENGTH_LONG).show();
}
else{
resultado.setText(getQR(result.getContents())); // <- <-
}
推荐阅读
- xamarin - appcenter 没有 **push** 选项?
- ios - 有没有结合 NSSet 和 FetchResult<> 的函数
- kubernetes - 在新创建的 kubernetes 集群中启动 POD 时出错 (ContainerCreating)
- flutter - Flutter:如何为构建器手动设置索引?
- ios - IAP 是强制性的吗?
- angular - 如何通过单击引导导航选项卡中一个选项卡中的锚链接导航到另一个选项卡
- r - R:用一个测量值可视化两组相关性的图?
- javascript - 无法访问在本地节点服务器上创建的 API
- php - Queue::fake 不适用于 Laravel5 代码接收模块
- django - 在 Django 项目中使用 DNA 信息的 CSV 作为数据库的有效方法