【问题标题】:xamarin android intent filter force close (Emulator)xamarin android意图过滤器强制关闭(模拟器)
【发布时间】:2015-11-10 08:15:09
【问题描述】:

我想使用 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)

【问题讨论】:

    标签: android xamarin intentfilter


    【解决方案1】:

    我知道使用 'using' 是很好的实践,但想知道 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);
    

    【讨论】:

    • 先生,我也试过了。还是强行关闭。当我尝试按代码调试时,没有错误。它只是打开布局 2-3 秒然后关闭。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-05-14
    • 1970-01-01
    • 1970-01-01
    • 2021-08-30
    • 1970-01-01
    • 2016-07-20
    • 1970-01-01
    相关资源
    最近更新 更多