Pregunta

well i have a problem with a mono android app, i'm starting an activity in implicit way, with this code:

        Android.Net.Uri uri = Android.Net.Uri.Parse( URL );
    Intent intent = new Intent (Intent.ActionView, uri);
    Intent chooserIntent = Intent.CreateChooser (intent, CHOOSER_TEXT);
    StartActivity (chooserIntent);

where URL is just "http://www.google.com"

the chooser dialog appears and shows a browser and my app that has browseable permission, but when i select it, it just cause an exception and it stops. Looking throug logcat found this:

if i start manually the activity, in logcat i can see this name of the activity being created MyBrowser.MyBrowser/mybrowser.MyBrowserActivity

but when is called through the chooser the activity is called in this way MyBrowser.MyBrowser/mybrowser.mybrowser.MyBrowserActivity

dont know why is adding the extra "mybrowser"

edit: here is the complete androidmanifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="mybrowser">
    <uses-sdk />
    <application android:label="MyBrowser">
        <activity android:name=".MyBrowserActivity" android:label="MyBrowser">
      <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <data android:scheme="http" android:host="www.google.com" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE"/>
      </intent-filter>
    </activity>
    </application>
</manifest>
¿Fue útil?

Solución

You shouldn't specify it in AndroidManifest file, do it direct in activity class using attributes

[IntentFilter(new[] { Intent.ActionView }, DataScheme = "http", DataHost = "www.google.com", Categories = new string[] {Intent.CategoryDefault, Intent.CategoryBrowsable})]
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top