- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我正在开发 Xamarin.Forms 应用。它运行良好,但当用户在打开其他几个应用程序后将其从后台恢复时,它会继续崩溃。我是 Xamarin 的新手,我不确定如何调试此问题。到目前为止,此问题未在 iOS 上发生。
飞溅 Activity .cs:
using System.Threading.Tasks;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Support.V7.App;
using Android.Util;
namespace MyApp.Droid
{
[Activity(Theme = "@style/MyTheme.Splash", MainLauncher = true, NoHistory = true)]
public class SplashActivity : AppCompatActivity
{
static readonly string TAG = "X:" + typeof(SplashActivity).Name;
protected override void OnCreate(Bundle savedInstanceState) // PersistableBundle persistentState
{
base.OnCreate(savedInstanceState); // persistentState
Log.Debug(TAG, "SplashActivity.OnCreate");
}
protected override void OnResume()
{
base.OnResume();
Task startupWork = new Task(() =>
{
Log.Debug(TAG, "Performing some startup work that takes a bit of time.");
Task.Delay(5000); // Simulate a bit of startup work.
Log.Debug(TAG, "Working in the background - important stuff.");
});
startupWork.ContinueWith(t =>
{
Log.Debug(TAG, "Work is finished - start Activity1.");
StartActivity(new Intent(Application.Context, typeof(MainActivity)));
}, TaskScheduler.FromCurrentSynchronizationContext());
startupWork.Start();
}
}
}
主 Activity .cs:
using System;
using Android.App;
using Android.Content;
using Android.Content.PM;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
using HockeyApp.Android;
using HockeyApp.Android.Metrics;
using Xamarin.Android.Net; // Keep to make TLS 1.2 work
namespace MyApp.Droid
{
[Activity(Label = "EventingVolunteers.Droid", Icon = "@drawable/icon", Theme = "@style/MyTheme", ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
protected override void OnCreate(Bundle savedInstanceState)
{
TabLayoutResource = Resource.Layout.Tabbar;
ToolbarResource = Resource.Layout.Toolbar;
base.OnCreate(savedInstanceState);
global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
LoadApplication(new App());
// HockeyApp
CrashManager.Register(this, Constants.HockeyAppID_Android);
MetricsManager.Register(this, Application, Constants.HockeyAppID_Android);
// Push Notifications
RegisterForGCM();
}
private void RegisterForGCM()
{
string senders = Constants.GoogleConsoleProjectId;
Intent intent = new Intent("com.google.android.c2dm.intent.REGISTER");
intent.SetPackage("com.google.android.gsf");
intent.PutExtra("app", PendingIntent.GetBroadcast(this, 0, new Intent(), 0));
intent.PutExtra("sender", senders);
StartService(intent);
}
protected override void OnPause()
{
base.OnPause();
}
protected override void OnResume()
{
base.OnResume();
}
protected override void OnDestroy()
{
base.OnDestroy();
}
}
}
错误信息:
java.lang.IllegalStateException: Fragment does not have a view
android.support.v4.app.Fragment$1.onFindViewById()Fragment.java:1933
android.support.v4.app.FragmentManagerImpl.moveToState()FragmentManager.java:1057
android.support.v4.app.FragmentManagerImpl.moveToState()FragmentManager.java:1252
android.support.v4.app.FragmentManagerImpl.moveToState()FragmentManager.java:1234
android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated()FragmentManager.java:2046
android.support.v4.app.Fragment.performActivityCreated()Fragment.java:1989
android.support.v4.app.FragmentManagerImpl.moveToState()FragmentManager.java:1092
android.support.v4.app.FragmentManagerImpl.moveToState()FragmentManager.java:1252
android.support.v4.app.FragmentManagerImpl.moveToState()FragmentManager.java:1234
android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated()FragmentManager.java:2046
android.support.v4.app.FragmentController.dispatchActivityCreated()FragmentController.java:174
android.support.v4.app.FragmentActivity.onStart()FragmentActivity.java:598
md5b60ffeb829f638581ab2bb9b1a7f4f3f.FormsAppCompatActivity.n_onStart(Native Method)
md5b60ffeb829f638581ab2bb9b1a7f4f3f.FormsAppCompatActivity.onStart()FormsAppCompatActivity.java:120
android.app.Instrumentation.callActivityOnStart()Instrumentation.java:1260
android.app.Activity.performStart()Activity.java:6261
android.app.ActivityThread.performLaunchActivity()ActivityThread.java:2389
android.app.ActivityThread.handleLaunchActivity()ActivityThread.java:2490
at android.app.ActivityThread.-wrap11(ActivityThread.java)
android.app.ActivityThread$H.handleMessage()ActivityThread.java:1354
android.os.Handler.dispatchMessage()Handler.java:102
android.os.Looper.loop()Looper.java:148
android.app.ActivityThread.main()ActivityThread.java:5456
java.lang.reflect.Method.invoke(Native Method)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run()ZygoteInit.java:728
com.android.internal.os.ZygoteInit.main()ZygoteInit.java:618
Xamarin caused by: Java.Lang.IllegalStateException: Fragment does not have a view
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
Java.Interop.JniEnvironment.InstanceMethods.CallNonvirtualVoidMethod(JniObjectReference instance, JniObjectReference type, JniMethodInfo method, JniArgumentValue* args)
Java.Interop.JniPeerMembers.JniInstanceMethods.InvokeVirtualVoidMethod(string encodedMember, IJavaPeerable self, JniArgumentValue* parameters)
Android.App.Activity.OnStart()
Xamarin.Forms.Platform.Android.FormsAppCompatActivity.OnStart()
Android.App.Activity.n_OnStart(IntPtr jnienv, IntPtr native__this)
at (wrapper dynamic-method) System.Object:23d8bc20-60cf-4cac-a339-6cc6722e8667 (intptr,intptr)
--- End of managed Java.Lang.IllegalStateException stack trace ---
java.lang.IllegalStateException: Fragment does not have a view
android.support.v4.app.Fragment$1.onFindViewById()Fragment.java:1933
android.support.v4.app.FragmentManagerImpl.moveToState()FragmentManager.java:1057
android.support.v4.app.FragmentManagerImpl.moveToState()FragmentManager.java:1252
android.support.v4.app.FragmentManagerImpl.moveToState()FragmentManager.java:1234
android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated()FragmentManager.java:2046
android.support.v4.app.Fragment.performActivityCreated()Fragment.java:1989
android.support.v4.app.FragmentManagerImpl.moveToState()FragmentManager.java:1092
android.support.v4.app.FragmentManagerImpl.moveToState()FragmentManager.java:1252
android.support.v4.app.FragmentManagerImpl.moveToState()FragmentManager.java:1234
android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated()FragmentManager.java:2046
android.support.v4.app.FragmentController.dispatchActivityCreated()FragmentController.java:174
android.support.v4.app.FragmentActivity.onStart()FragmentActivity.java:598
md5b60ffeb829f638581ab2bb9b1a7f4f3f.FormsAppCompatActivity.n_onStart(Native Method)
md5b60ffeb829f638581ab2bb9b1a7f4f3f.FormsAppCompatActivity.onStart()FormsAppCompatActivity.java:120
android.app.Instrumentation.callActivityOnStart()Instrumentation.java:1260
android.app.Activity.performStart()Activity.java:6261
android.app.ActivityThread.performLaunchActivity()ActivityThread.java:2389
android.app.ActivityThread.handleLaunchActivity()ActivityThread.java:2490
at android.app.ActivityThread.-wrap11(ActivityThread.java)
android.app.ActivityThread$H.handleMessage()ActivityThread.java:1354
android.os.Handler.dispatchMessage()Handler.java:102
android.os.Looper.loop()Looper.java:148
android.app.ActivityThread.main()ActivityThread.java:5456
java.lang.reflect.Method.invoke(Native Method)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run()ZygoteInit.java:728
com.android.internal.os.ZygoteInit.main()ZygoteInit.java:618
--- End of managed Java.Lang.IllegalStateException stack trace ---
java.lang.IllegalStateException: Fragment does not have a view
android.support.v4.app.Fragment$1.onFindViewById()Fragment.java:1933
android.support.v4.app.FragmentManagerImpl.moveToState()FragmentManager.java:1057
android.support.v4.app.FragmentManagerImpl.moveToState()FragmentManager.java:1252
android.support.v4.app.FragmentManagerImpl.moveToState()FragmentManager.java:1234
android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated()FragmentManager.java:2046
android.support.v4.app.Fragment.performActivityCreated()Fragment.java:1989
android.support.v4.app.FragmentManagerImpl.moveToState()FragmentManager.java:1092
android.support.v4.app.FragmentManagerImpl.moveToState()FragmentManager.java:1252
android.support.v4.app.FragmentManagerImpl.moveToState()FragmentManager.java:1234
android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated()FragmentManager.java:2046
android.support.v4.app.FragmentController.dispatchActivityCreated()FragmentController.java:174
android.support.v4.app.FragmentActivity.onStart()FragmentActivity.java:598
md5b60ffeb829f638581ab2bb9b1a7f4f3f.FormsAppCompatActivity.n_onStart(Native Method)
md5b60ffeb829f638581ab2bb9b1a7f4f3f.FormsAppCompatActivity.onStart()FormsAppCompatActivity.java:120
android.app.Instrumentation.callActivityOnStart()Instrumentation.java:1260
android.app.Activity.performStart()Activity.java:6261
android.app.ActivityThread.performLaunchActivity()ActivityThread.java:2389
android.app.ActivityThread.handleLaunchActivity()ActivityThread.java:2490
at android.app.ActivityThread.-wrap11(ActivityThread.java)
android.app.ActivityThread$H.handleMessage()ActivityThread.java:1354
android.os.Handler.dispatchMessage()Handler.java:102
android.os.Looper.loop()Looper.java:148
android.app.ActivityThread.main()ActivityThread.java:5456
java.lang.reflect.Method.invoke(Native Method)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run()ZygoteInit.java:728
com.android.internal.os.ZygoteInit.main()ZygoteInit.java:618
App.xaml.cs:
using System;
using System.Linq;
using Amazon;
using Xamarin.Forms;
namespace MyApp
{
public partial class App : Application
{
public static string AppName { get { return "MyApp"; } }
public static User User { get; set; }
public static UserManager UserManager { get; private set; }
public static VolunteerManager VolunteerManager { get; private set; }
public static SignupManager SignupManager { get; private set; }
static NavigationPage NavPage;
public static bool IsLoggedIn
{
get
{
if (User != null)
return !string.IsNullOrWhiteSpace(User.Email);
else
return false;
}
}
public static Action SuccessfulLoginAction
{
get
{
return new Action(() =>
{
NavPage.Navigation.PopModalAsync();
if (IsLoggedIn)
{
// Update RestService with new token
UserManager = new UserManager(new RestService());
VolunteerManager = new VolunteerManager(new RestService());
SignupManager = new SignupManager(new RestService());
NavPage.Navigation.InsertPageBefore(new VolunteerDashboardPage(), NavPage.Navigation.NavigationStack.First());
NavPage.Navigation.PopToRootAsync();
}
});
}
}
public static Action LogoutAction
{
get
{
return new Action(() =>
{
DependencyService.Get<ICredentialsService>().DeleteCredentials();
App.User = null;
// NavPage.Navigation.PopModalAsync();
NavPage.Navigation.InsertPageBefore(new LoginPage(), NavPage.Navigation.NavigationStack.First());
NavPage.Navigation.PopToRootAsync();
});
}
}
public App()
{
User = new User();
UserManager = new UserManager(new RestService());
VolunteerManager = new VolunteerManager(new RestService());
SignupManager = new SignupManager(new RestService());
// AWS SDK
var loggingConfig = AWSConfigs.LoggingConfig;
loggingConfig.LogMetrics = true;
loggingConfig.LogResponses = ResponseLoggingOption.Always;
loggingConfig.LogMetricsFormat = LogMetricsFormatOption.JSON;
loggingConfig.LogTo = LoggingOptions.SystemDiagnostics;
//AWSConfigs.AWSRegion = "us-east-1";
// Check if login needed
if (DependencyService.Get<ICredentialsService>().DoCredentialsExist())
{
NavPage = new NavigationPage(new VolunteerDashboardPage());
MainPage = NavPage;
// MainPage = new VolunteerDashboardPage();
} else {
NavPage = new NavigationPage(new LoginPage());
MainPage = NavPage;
}
}
protected override void OnStart()
{
// Handle when your app starts
}
protected override void OnSleep()
{
// Handle when your app sleeps
}
protected override void OnResume()
{
// Handle when your app resumes
}
}
}
最佳答案
添加 nuget 包 AndroidX.Fragment 版本“1.2.5.4”对我有用。仅当我选择开发者选项时才能重现 -> 不要保留 Activity
关于android - Xamarin.Forms.Android : java. lang.IllegalStateException: fragment 没有 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39068772/
我的设置.py: LANGUAGE_CODE = 'de' TIME_ZONE = require_env("TIME_ZONE_IDENTIFIER") USE_I18N = True USE_L1
谁能给我解释一下 Django 的 forms.Form 和 forms.ModelForm 的相同点和不同点? 最佳答案 从 forms.Form 创建的表单由您手动配置。您最好将这些用于不直接与模
我在用 angularjs 构建的表单上遇到此错误。 `错误:[$compile:multidir] 多个指令 [form, form] 请求 'form' Controller :
我是 Spring 的新手,在尝试显示表单错误时遇到了一些麻烦。 我有以下表格: User Name:
我希望在提交表单时找出 spring:bind 和 form:form 标记库之间的区别。 我的 JSP 片段如下: ....
类型‘AbstractControl’上不存在属性‘Controls’。
有一个问题与此非常相似,但我想以不同的方式提出。 我是一个非常自定的人,但有时我确实喜欢走捷径。就这样吧。 我确实发现这两个类非常相似,尽管其中一个“帮助”程序员更快地编写代码或减少代码/重复代码。将
我在控制台中收到此错误。 “表单提交已取消,因为表单未连接” 自从我们将应用程序迁移到更新版本的 React 后,尝试将我的 redux-form 从 v5 迁移到 v6 之后。 我不确定这里出了什么
我想要的是一个表单,在提交时运行验证检查,并突出显示所有无效字段并添加工具提示。 我正在有效地寻找这样的东西: dojo.forEach(dijit.byId('myForm')._invalidWi
我需要设置symfony2表单元素的值。 我在 Controller 操作中使用了doctrine2实体, Symfony\Component\Form\AbstractType 和createFor
这是用于将数据提交到自定义列表的自定义 Editform.aspx。用户完成表单后,他应该能够点击按钮甚至“确定”按钮,并让 sharepoint 将表单数据提交到列表,然后重定向到项目显示表单 (d
我想知道在 spring 标签中编写所有表单是否是一种好习惯,或者我可以将 spring 表单标签与 html 表单标签混合使用吗? 最佳答案 当您需要 Spring 表单提供的功能时使用它们: 绑定
我正在构建动态表单并希望“即时”添加表单组。 这是我的代码,几乎可以工作: import {Component, OnInit} from '@angular/core'; import {FormG
表格 Form.Load 有什么区别? , Form.Shown和 Form.Activated事件?他们被解雇的顺序是什么? 最佳答案 参见 Windows Forms Events Lifecyc
我正在使用具有路线跟踪功能的 Xamarin Forms 开发一些应用程序。尽管我正在使用 AppCenter,即在 App.xaml.cs OnStart 我添加 protected asy
我正在实现一个 gameboy 模拟器,就像我之前的许多人一样。 我正在尝试实现 PPU 并为此使用代表屏幕的类。 // needed because VS can't find it as depe
我是 Orbeon Form 新手,想使用它。不过,我尝试过 Orbeon Form 网站上的 Form 示例,并用泰语输入了一些数据。是的,可以在“泰语”字段中输入数据。但是当我尝试生成“PDF”时
那么让表单一遍又一遍有效地呈现相同表单的最佳方法是什么,并根据实体的属性值有条件地禁用字段? 我有一个发票实体,需要一个用于创建发票的表单,以及在发票流程的各个阶段(生成、发送、支付等)禁用各个字段的
因此,我一直在与我的同事(开发人员和设计人员)就 Web 表单的自动填充工具进行亲切的辩论。这是一个重要的开发问题,因为它会影响表单的构建方式。 问)自动填充工具(例如 Google 工具栏或 Chr
那么让表单一遍又一遍有效地呈现相同表单的最佳方法是什么,并根据实体的属性值有条件地禁用字段? 我有一个发票实体,需要一个用于创建发票的表单,以及在发票流程的各个阶段(生成、发送、支付等)禁用各个字段的
我是一名优秀的程序员,十分优秀!