[英]How do I use “#” in Uri.parse in android programming
I am trying to parse a *123#
in my code but anytime I run the program the #
never seems to appear: 我试图在代码中解析*123#
,但是无论何时运行程序, #
似乎都不会出现:
protected void makeCall(){
Log.i("make call", "");
Intent phoneIntent = new Intent(Intent.ACTION_CALL);
phoneIntent.setData(Uri.parse("tel: *123#"));
try{
startActivity(phoneIntent);
finish();
Log.i("finish making call...", "");
}catch (android.content.ActivityNotFoundException ex){
Toast.makeText(MainActivity.this,"call failed",Toast.LENGTH_LONG).show();
}
}
Please help me out with this. 这个你能帮我吗。
protected void makeCall(){
Log.i("make call", "");
Intent phoneIntent = new Intent(Intent.ACTION_CALL);
phoneIntent.setData(Uri.parse("tel:*123#"));
try{
startActivity(phoneIntent);
// finish();
Log.i("finish making call...", "");
}catch (android.content.ActivityNotFoundException ex){
Toast.makeText(MainActivity.this,"call failed",Toast.LENGTH_LONG).show();
}
}
Must add <uses-permission android:name="android.permission.CALL_PHONE" />
in Manifest as well. 还必须在清单中添加<uses-permission android:name="android.permission.CALL_PHONE" />
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.