Rhomobile:自定义URL方案

时间:2011-12-21 15:07:34

标签: ruby rhomobile rhodes

我正在编写针对iPhone和Android的Rhomobile应用程序 我需要创建一个自定义网址方案,以便我可以创建看起来像test://some-params的网址,它将启动我的程序并将其传递给params。

据我所知,这是通过BundleURLScheme参数在build.yml中完成的,然后是System.get_start_params()来获取这些参数。 但是,据我所知,这只适用于iPhone。 有没有办法让这个在Android上运行呢?

非常感谢!

1 个答案:

答案 0 :(得分:1)

好的,我自己也找到了答案,万一有人也需要这个答案:

  • 按照此处的说明创建应用程序的扩展: http://docs.rhomobile.com/rhodes/extensions#generating-a-native-extension-template
  • 添加一个android_manifest_changes文件,如上面链接中所述。
  • 在该文件中添加以下行:

    <manifest xmlns:android='http://schemas.android.com/apk/res/android'
    android:versionName='1.0' package='com.rhomobile.webbrowserpoc'
    android:versionCode='10000' android:installLocation='auto'>
    <application android:name='com.rhomobile.rhodes.RhodesApplication'
        android:label='@string/app_name' android:icon='@drawable/icon'
        android:debuggable='true'>
        <activity android:name='com.rhomobile.rhodes.RhodesActivity'
            android:label='@string/app_name' android:launchMode='singleTask'
            android:configChanges='orientation|keyboardHidden'
            android:screenOrientation='unspecified'>
            <intent-filter>
                <action android:name='android.intent.action.VIEW' />
                <category android:name='android.intent.category.BROWSABLE' />
                <category android:name='android.intent.category.DEFAULT' />
                <data android:pathPrefix='' android:scheme=''
                    android:host='' />
            </intent-filter>
        </activity>
    </application>
    

只应使用正确的属性填写<data android:pathPrefix='' android:scheme='' android:host='' />行。

相关问题