有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java为什么我的Uri不是通过安卓中的ACTION_DIAL获取的?

我发现以下代码工作得很好:

Intent intent = new Intent( Intent.ACTION_DIAL , Uri.parse("tel:555-2368") );

但当我尝试下面的代码时,它不起作用。我试图通过读取文件来创建URI

File f = new File ( "tushar.txt") ;
f.createNewFile() ;

fw = new FileWriter(f) ;
bfr = new BufferedWriter(fw);
bfr.write("9654309293") ;
bfr.write("9876543210") ;
Uri u = Uri.fromFile(f) ;

Intent intent =
new Intent(Intent.ACTION_DIAL, u);

共 (1) 个答案

  1. # 1 楼答案

    试试这个-

    File f = new File ( "tushar.txt") ;
    f.createNewFile() ;
    
    fw = new FileWriter(f) ;
    bfr = new BufferedWriter(fw);
    bfr.write("tel:9654309293") ;
    bfr.write("tel:9876543210") ;
    bfr.flush();
    fw.close();
    Uri u = Uri.fromFile(f) ;
    
    Intent intent =
    new Intent(Intent.ACTION_DIAL, u);