Kodi Community Forum
Exception when starting external player - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32)
+--- Forum: Kodi Application (https://forum.kodi.tv/forumdisplay.php?fid=93)
+---- Forum: Android Development (https://forum.kodi.tv/forumdisplay.php?fid=184)
+---- Thread: Exception when starting external player (/showthread.php?tid=171689)



Exception when starting external player - arikhalperin - 2013-08-20

Hello,

When trying to start my own player, I encountered the following exception:

E/AndroidRuntime( 2365): FATAL EXCEPTION: Thread-122
E/AndroidRuntime( 2365): java.lang.NullPointerException: pattern == null
E/AndroidRuntime( 2365): at java.util.regex.Pattern.compile(Pattern.java:388)
....(Saving the space)...
E/AndroidRuntime( 2365): at dalvik.system.NativeStart.run(Native Method)
W/ActivityManager( 1402): Force finishing activity org.xbmc.xbmc/.Main
D/dalvikvm( 1402): GC_FOR_ALLOC freed 691K, 30% free 11998K/17095K, paused 134ms

The root cause of this is that the function that starts the external player does not set the mime type for the URI I'm playing. Here is a diff of my fix:

diff --git a/xbmc/android/activity/XBMCApp.cpp b/xbmc/android/activity/XBMCApp.cpp
index 9f8e8c1..428f3c8 100644
--- a/xbmc/android/activity/XBMCApp.cpp
+++ b/xbmc/android/activity/XBMCApp.cpp
@@ -398,17 +398,23 @@ bool CXBMCApp::HasLaunchIntent(const string &package)
// Note intent, dataType, dataURI all default to ""
bool CXBMCApp::StartActivity(const string &package, const string &intent, const string &dataType, const string &dataURI)
{
+
+ android_printf("StartActivity: package=%s intent=%s dataType=%s dataURI=%s",package.c_str(), intent.c_str(), dataType.c_str(), dataURI.c_str());
+
CJNIIntent newIntent = GetPackageManager().getLaunchIntentForPackage(package);
if (!newIntent)
return false;

+ CJNIURI jniURI= CJNIURI::parse(dataURI);
+
if (!dataURI.empty())
- newIntent.setData(dataURI);
+ newIntent.setDataAndType(jniURI,dataType);

if (!intent.empty())
newIntent.setAction(intent);

- startActivity(newIntent);
+ startActivity(newIntent);
+
return true;
}

With Best Regards,
Arik Halperin


RE: Exception when starting external player - Memphiz - 2013-08-27

Could you do this as a pull request to http://github.com/xbmc/xbmc please?