android - 如何在android中打开本地文件

时间:2013-04-05 06:31:48

标签: android file kml

我正在尝试打开我的sdcard中的本地kml文件但是我收到错误。在stackoverflow本身我看到了一些与此相关的问题,但它们没有得到解答,有些与此无关。

android - how to open kml file in android

Android - How to open google maps with Intent and KML?

我的代码

public void openKMLFile(View v)

    final Intent myIntent = new Intent(android.content.Intent.ACTION_VIEW, 
            Uri.parse("geo:0,0?q=file://" + Environment.getExternalStorageDirectory() + "/test.kml"));
    startActivity(myIntent);
}

Android Manifest文件我已经授予此权限

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.demo"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="16" />
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >

        <activity
            android:name="com.example.demo.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

Logcat错误:

04-05 11:42:01.806: E/AndroidRuntime(833): FATAL EXCEPTION: main
04-05 11:42:01.806: E/AndroidRuntime(833): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.demo/com.example.demo.MainActivity}: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=geo:0,0?q=file:///mnt/sdcard/10.kml }
04-05 11:42:01.806: E/AndroidRuntime(833): Caused by: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=geo:0,0?q=file:///mnt/sdcard/10.kml }

非常感谢您的帮助。谢谢您

0 个答案:

没有答案