xamarin android意图过滤器强制关闭(模拟器)

时间:2015-11-10 08:15:09

标签: android xamarin intentfilter

我想使用Android Intent-filter从另一个Activity打开我的Android页面。我已经搜索过这样的问题,并找到了一些答案,但是当我在我的源代码中尝试时,它不起作用。

我有代码调用url链接打开我的应用程序

       using (var uri = Android.Net.Uri.Parse("http://url.com/password/reset/confirm/MQ/46l-4e294a00ac5e43ee8a1b"))
       {
            using (var openIntent = new Intent(Intent.ActionView, uri))
            {
                activity.StartActivity(new Intent(openIntent));
            }
       }

然后我想调用我的Android页面,但总是强制关闭。这是代码

    [Activity(Label = "Qrawd")]
[IntentFilter(new[] { Intent.ActionView },
   DataScheme = "http",
   DataHost = "url.com",
   Categories = new[] { Android.Content.Intent.CategoryDefault, Android.Content.Intent.CategoryBrowsable })]

public class ResetPasswordPage : Activity
{
    String ui_id, token_id;
    protected override void OnCreate(Bundle bundle)
    {
        base.OnCreate(bundle);
        var data = Intent.Data;
        String scheme = data.Scheme; // "http"
        String host = data.Host; // "qrawd.com"
        IList<string> param = data.PathSegments;
        String first = param[0]; // "password"
        String second = param[1]; // "reset"
        String confirm = param[2]; // "confirm"
        ui_id = param[3]; // "ui_id"
        token_id = param[4]; // "token"

        SetContentView(Resource.Layout.ResetPasswordLayout);
    }
}

有时会出现错误,有时则没有。这是错误列表:

11-10 00:53:57.635 E/InputQueue-JNI( 2619): channel '410c9af0 com.nurosoft/md5e1b91645369ae8dea4dc20d1701359d7.MainActivity (client)' ~ Publisher closed input channel or an error occurred.  events=0x8
11-10 00:53:57.645 E/InputQueue-JNI( 2619): channel '41220c68 com.nurosoft/md588445bdc4f44543f0c63e6b1da45d3c9.ResetPasswordPage (client)' ~ Publisher closed input channel or an error occurred.  events=0x8
11-10 00:53:57.694 I/ActivityThread( 2619): Removing dead content provider: settings
11-10 00:53:57.744 E/SurfaceTextureClient( 2619): queueBuffer: error queuing buffer to SurfaceTexture, -19
11-10 00:53:57.744 E/SurfaceTextureClient( 2619): queueBuffer (handle=0x19ae4c0) failed (No such device)
11-10 00:53:57.744 D/AndroidRuntime( 2619): Shutting down VM
11-10 00:53:57.744 W/dalvikvm( 2619): threadid=1: thread exiting with uncaught exception (group=0x409bf1f8)

1 个答案:

答案 0 :(得分:0)

我知道使用&#39;使用&#39;很好,但想知道Activity生命周期是否提前关闭了Activity / Intent,如果你只是使用会发生什么;

var uri = Android.Net.Uri.Parse("http://url.com/password/reset/confirm/MQ/46l-4e294a00ac5e43ee8a1b");
var openIntent = new Intent(Intent.ActionView, uri);
activity.StartActivity(new Intent(openIntent);