android - 将第 3 方 Android JAR 集成到 Titanium Mobile 应用程序中?

标签 android mobile jar android-intent titanium

我正在编写一个尝试播放 YouTube 视频的 Titanium 应用程序。目标是让用户留在应用程序中,所以调用 native youtube 应用程序是不可能的,我已经可以做到这一点。我有适用于 iOS 的代码,但只是因为嵌入webView 支持内容。不幸的是,Android 的情况并非如此。

好像http://code.google.com/p/android-youtube-player/wiki/OpenYouTubePlayerActiviyInstructions会解决我的问题,但我不确定如何从 Titanium 中使用它。文档建议从 Android 执行此操作:

Intent lVideoIntent = new Intent(null, Uri.parse("ytpl://"+YOUTUBE_PLAYLIST_ID), this, OpenYouTubeActivity.class);//public Intent (String action, Uri uri, Context packageContext, Class<?> cls) from Android doc
startActivity(lVideoIntent);

因此,利用 http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.Android.Intent-object.htmlhttp://developer.appcelerator.com/apidoc/mobile/latest/Titanium.Android.Activity-object.html作为向导,想出了:

var intent = Ti.Android.createIntent({
            action: 'null',
            data: 'ytv://'+vguid,
            packageName: 'com.keyes.youtube',
            className: 'com.keyes.youtube.OpenYouTubeActivity'
        });
        Ti.Android.Activity.startActivity(intent);

在我的 TiApp.XML 中,我添加了这个:

<android xmlns:android="http://schemas.android.com/apk/res/android">
        <uses-permission android:name="android.permission.WAKE_LOCK"></uses-permission> 
        <uses-permission android:name="android.permission.INTERNET"></uses-permission> 
        <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"></uses-permission>
        <activity android:name="com.keyes.youtube.OpenYouTubePlayerActivity"></activity>
    </android>

当我尝试运行代码时,出现以下错误: 类型错误:无法调用未定义的方法“startActivity”(文件:///android_asset/Resources/app.js#162) 其中 162 是 startActivity(intent) 的行号;

我认为这与源不在类路径中有关(我试过只使用他的 .jar 以及单独的 .java 文件)和/或它没有被用作模块。我使用了一个 iOS 模块,但不知道如何编写我自己的 Android 模块,更不用说将别人的代码移植到模块中了。

有什么帮助吗?我敢肯定,这是很多 Titanium 用户都在纠结的问题。

编辑 1

我在这方面取得了一些进展,但仍然没有解决方案。我已经走了“模块”路线,因为我还没有看到另一种方法来获取项目构建中包含的 jars/java 文件。我将模块构建为“ytModule”,并通过添加

将其包含在内
<module version="0.1">com.keyes.ytModule</module>

到 tiapp.xml。然后我得到

[DEBUG] Looking for Titanium Module id: com.keyes.ytModule, version: 0.1, platform: <any platform>
[DEBUG] module_id = com.keyes.ytModule
[DEBUG] appending module: com.keyes.ytModule.YtplayerModule

当我从 TitaniumStudio 构建时。我正在努力解决这个问题,并将继续发布更新/尝试建议

最佳答案

关于android - 将第 3 方 Android JAR 集成到 Titanium Mobile 应用程序中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6102760/

相关文章:

php - opencart 检测移动设备并重定向到移动主题

android - 如何实时更新客户端库逻辑?

java - 使用自定义类路径使用 GraalVM native 镜像命令行?

java - 无法在 Ubuntu 14.04 上运行 Weka 资源管理器

java - 获取Android LRUCache当前使用的内存

java - 使用 Google App Engine 作为 Android 应用程序后端的示例

Android 在上传到服务器之前压缩视频

javascript - 谷歌地图 API v3 : custom markers not clickable on mobile devices

java - 为什么Maven打出来的包没有附带依赖?

android - 在 Android 中单击后使标记可拖动