自定义方案似乎没有在应用程序意图中启动

Cyl*_*ric 4 android oauth

我正在尝试创建一个需要使用OAuth进行身份验证的Android应用(使用Google Wave数据API)

我在我的指定了一个自定义方案,AndroidManifest.xml以便任何以"braindump://"开头的网址的视图应该转到我的应用:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="org.enigmagen.braindump"
    android:versionName="0.1"
    android:versionCode="1">

    <uses-sdk android:minSdkVersion="7"></uses-sdk>
    <uses-permission android:name="android.permission.INTERNET"></uses-permission>

    <application
        android:icon="@drawable/icon"
        android:label="@string/app_name"
        android:debuggable="true">

        <activity
            android:name=".BrainDump"
            android:label="@string/app_name"
            android:launchMode="singleInstance">

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data android:scheme="braindump" />
            </intent-filter>

        </activity>

    </application>

</manifest>
Run Code Online (Sandbox Code Playgroud)

所有这一切都发生在重定向之后,浏览器地址显示正确的URL,但页面内容是

您无权打开此页面.题库:// rest_of_address_here

是否需要设置特定权限才能允许此类行为?

Adr*_*nei 8

我有完全相同的问题(OAuth),这就是我修复它的方法.

我已将我的Main与将作用于URI的类分开.

以下是AndroidManifest.xml的外观:

<?xml version="1.0" encoding="utf-8"?>

[snip]

          <activity android:label="@string/app_name" android:name="MainActivity">
           <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
           </intent-filter>
          </activity>
          <activity android:label="@string/app_name" android:name="OAUTHActivity">
           <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:scheme="myscheme" android:host="oauth" />
           </intent-filter>
          </activity>
         </application>

    [/snip]
Run Code Online (Sandbox Code Playgroud)

我能够打开像这样的URI myscheme//oauth?oauth_verifier=xxx&oauth_token=yyy


小智 5

实际上,只用一个活动就可以做到这一点,只需再创建一个intent过滤器.像这样:

<activity android:name=".MyActivity"
      android:label="@string/app_name">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
    <intent-filter>
        <action   android:name="android.intent.action.VIEW"/>     
        <category android:name="android.intent.category.DEFAULT"/>
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="my_scheme" android:host="my_app_host.com" />
    </intent-filter>
</activity>
Run Code Online (Sandbox Code Playgroud)


Pen*_*m10 0

根据常见任务应该是:

<scheme android:name="braindump" />
Run Code Online (Sandbox Code Playgroud)