¿Puedo obtener una devolución de llamada en la clase de aplicación siempre que se inicie una nueva actividad en toda la aplicación?
Mi aplicación utiliza la biblioteca de inicio de sesión de terceros y algunas otras bibliotecas . que abre sus propias actividades.
Solo quiero notificar a mi aplicación cuando se activa alguna actividad. por ejemplo, siempre que se abra una pantalla Actividad para llamadas desde mi aplicación.
- Cómo configurar onclick oyente en xamarin?
- ObjectAnimator Proxy para animar TopMargin no puede encontrar setting / getter
- ¿Cómo usar la Facturación en la aplicación con MonoDroid?
- Cómo sincronizar dos posiciones de ListView
- Mono.Data.Sqlite.SqliteConnection.SetConfig lanza una biblioteca utilizada incorrectamente excepción
- Xamarin C # - Android - Impedir que un AlertDialog cierre en PositiveButton haga clic
- Error: JNI ERROR (bug de la aplicación): se accede a la referencia global obsoleta
- Xamarin Forms - Media Plugin - Vaciar las miniaturas en el teléfono
- Cómo transmitir datos de MediaCodec a AudioTrack con Xamarin para Android
- Cómo pasar el parámetro al método java desde c # en JNI
- Cómo cerrar la actividad de Android con visual studio y xamarin
- Portar Card.IO a C # Xamarin Studio
- Cómo se utiliza la clase BluetoothA2dp en Xamarin
Aquí está el ejemplo perfecto
Parece que este código en Xamarin Android (C #)
https://developer.android.com/reference/android/app/Application.ActivityLifecycleCallbacks.html
es poco similar a lo que estoy buscando
http://xandroid4net.blogspot.in/2013/11/how-to-capture-unhandled-exceptions.html
[Application] class UnhandledExceptionExampleApplication : Application, Application.IActivityLifecycleCallbacks { private Activity _CurrentActivity; public Activity CurrentActivity { get { return _CurrentActivity; } set { _CurrentActivity = value; } } public UnhandledExceptionExampleApplication(IntPtr handle, JniHandleOwnership transfer) : base(handle, transfer) { } public override void OnCreate() { base.OnCreate(); AndroidEnvironment.UnhandledExceptionRaiser += (sender, args) => { /* * When the UI Thread crashes this is the code that will be executed. There is no context at this point * and no way to recover from the exception. This is where you would capture the error and log it to a * file for example. You might be able to post to a web handler, I have not tried that. * * You can access the information about the exception in the args.Exception object. */ }; AppDomain.CurrentDomain.UnhandledException += (s, e) => { /* * When a background thread crashes this is the code that will be executed. You can * recover from this. * You might for example: * _CurrentActivity.RunOnUiThread(() => Toast.MakeText(_CurrentActivity, "Unhadled Exception was thrown", ToastLength.Short).Show()); * * or * * _CurrentActivity.StartActivity(typeof(SomeClass)); * _CurrentActivity.Finish(); * * It is up to the developer as to what he/she wants to do here. * * If you are requiring a minimum version less than API 14, you would have to set _CurrentActivity in each time * the a different activity is brought to the foreground. */ }; } // IActivityLifecycleCallbacks Requires App to target API 14 and above. This can be used to keep track of the current Activity #region IActivityLifecycleCallbacks Members public void OnActivityCreated(Activity activity, Bundle savedInstanceState) { _CurrentActivity = activity; //throw new NotImplementedException(); } public void OnActivityDestroyed(Activity activity) { //throw new NotImplementedException(); } public void OnActivityPaused(Activity activity) { //throw new NotImplementedException(); } public void OnActivityResumed(Activity activity) { //throw new NotImplementedException(); } public void OnActivitySaveInstanceState(Activity activity, Bundle outState) { //throw new NotImplementedException(); } public void OnActivityStarted(Activity activity) { throw new NotImplementedException(); } public void OnActivityStopped(Activity activity) { throw new NotImplementedException(); } #endregion }
- Depuración de una biblioteca aar referenciada en Otro proyecto en Android Studio
- Cómo escalar los marcadores MapView de Android cuando un usuario amplía / desactiva