[Android] Util: display the NativeCrashActivity when a native crash occurs in LibVLC

Adrien Maglo git at videolan.org
Thu May 8 11:50:58 CEST 2014


vlc-ports/android | branch: master | Adrien Maglo <magsoft at videolan.org> | Thu May  8 11:50:49 2014 +0200| [e48a0853163e866235b15c449c8f28d660f30b51] | committer: Adrien Maglo

Util: display the NativeCrashActivity when a native crash occurs in LibVLC

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=e48a0853163e866235b15c449c8f28d660f30b51
---

 vlc-android/src/org/videolan/vlc/Util.java |   13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/vlc-android/src/org/videolan/vlc/Util.java b/vlc-android/src/org/videolan/vlc/Util.java
index 139a06f..3f08bae 100644
--- a/vlc-android/src/org/videolan/vlc/Util.java
+++ b/vlc-android/src/org/videolan/vlc/Util.java
@@ -44,8 +44,10 @@ import org.videolan.libvlc.LibVLC;
 import org.videolan.libvlc.LibVlcException;
 import org.videolan.libvlc.LibVlcUtil;
 import org.videolan.libvlc.Media;
+import org.videolan.vlc.gui.NativeCrashActivity;
 
 import android.content.Context;
+import android.content.Intent;
 import android.content.SharedPreferences;
 import android.content.SharedPreferences.Editor;
 import android.content.res.TypedArray;
@@ -82,10 +84,19 @@ public class Util {
             Thread.setDefaultUncaughtExceptionHandler(new VlcCrashHandler());
 
             instance = LibVLC.getInstance();
-            Context context = VLCApplication.getAppContext();
+            final Context context = VLCApplication.getAppContext();
             SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context);
             updateLibVlcSettings(pref);
             instance.init(context);
+            instance.setOnNativeCrashListener(new LibVLC.OnNativeCrashListener() {
+                @Override
+                public void onNativeCrash() {
+                    Intent i = new Intent(context, NativeCrashActivity.class);
+                    i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+                    context.startActivity(i);
+                    android.os.Process.killProcess(android.os.Process.myPid());
+                }
+            });
         }
         return instance;
     }



More information about the Android mailing list