CMFileManager 文件打开

CMFileManager中,通过NavigationView.java的onItemClick方法触发文件打开。使用IntentsActionPolicy.openFileSystemObject()来调用intent ACTION_VIEW,通过MediaHelper.fileToContentUri()将文件转换为内容URI以便于在注册的应用中查看。此过程涉及到Android的文件系统操作和内容提供者。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

FileSystemObject

 

packages/apps/CMFileManager/src/com/cyanogenmod/filemanager/ui/widgets/

NavigationView.java

public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

  // Open the file (edit or pick)
            if (this.mNavigationMode.compareTo(NAVIGATION_MODE.BROWSABLE) == 0) {       
                // Open the file with the preferred registered app
                IntentsActionPolicy.openFileSystemObject(getContext(), fso, false, null, null);
            }

}

 

IntentsActionPolicy.java

openFileSystemObject(){

   intent.setAction(android.content.Intent.ACTION_VIEW);

   getUriFromFile();

   // Resolve the intent
    resolveIntent();//选择启动该文件的应用

}

    /**
     * Method that returns the best Uri for the file (content uri, file uri, ...)
     *
     * @param ctx The current context
     * @param file The file to resolve
     */
    private static Uri getUriFromFile(Context ctx, File file) {
        Uri uri = MediaHelper.fileToContentUri(ctx, file);

}

 

 

 

packages/apps/CMFileManager/src/com/cyanogenmod/filemanager/util/

MediaHelper.java

fileToContentUri(){

// Check in external and internal storages
        Uri uri = fileToContentUri(context, normalizedPath, EXTERNAL_VOLUME);

}

baseUri=content://media/external/images/media

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值