2015-11-10 79 views
0

我想用Android Intent-filter從另一個Activity打開我的Android頁面。我已經搜索了一些這樣的問題,並找到了一些答案,但是當我嘗試在我的來源,它不工作。xamarin android intent filter force close(Emulator)

我的代碼來調用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) 

回答

0

我知道這是使用「用好實踐的研究,但不知道是否該活動的生命週期早期的封閉活動/意圖,如果你只使用會發生什麼;

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); 
+0

我已經試過了,先生。仍然強行關閉。 當我試圖調試每個代碼時,沒有錯誤。它只需打開2-3秒的佈局,然後關閉。 –