开发者

startActivity with Action and Uri crash the app

I want to open a new activity and pass it a URI of local html file(which i开发者_运维知识库s in the assets of the project):

public void onClick(View v) 
{
    Intent i = new Intent("com.appstudio.android.MY_ACTION",Uri.parse("file:///android_asset/sfaradi_mazon.html"));
    MainActivity.this.startActivity(i);
}

And this is how i declared the responding activity in the Manifest:

<activity android:name="BlessingActivity">
        <intent-filter>
            <action android:name="com.appstudio.android.MY_ACTION"/>
            <data android:mimeType="text/html"/>
            <category android:name="android.intent.category.DEFAULT"/>
        </intent-filter>
</activity>

But for some reason the app is crashing at startActivity(Action, Uri).

I'm getting an ActivityNotFoundException. No Activity was found to handle the intent

Any ideas?

Thanks!


You have specified a MIME type in the <intent-filter> but do not have it in the corresponding Intent. Either remove the <data> element or call setDataAndType() on the Intent instead of supplying the Uri in the constructor.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜