我想使用Android Intent-filter从另一个活动中打开我的Android页面。我已经搜索了一些类似的问题,并找到了一些答案,但当我在我的源代码中尝试时,它不起作用。
我有代码调用url link来打开我的应用程序,如下所示
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)
发布于 2015-11-10 21:36:50
我知道使用' using‘是一个很好的实践,但是想知道如果活动生命周期提前结束了活动/意图,如果你只是使用会发生什么;
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);
https://stackoverflow.com/questions/33625466
复制相似问题