定制方案似乎并没有在应用程序的意图发动

问题描述:

我试图创建一个Android应用程序需要使用OAuth认证(与谷歌Wave API数据)定制方案似乎并没有在应用程序的意图发动

我指定了一个自定义方案在我AndroidManifest.xml以便于一个URL的观点开始“题库://”应该去我的应用程序:

<?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> 

所发生的一切虽然是重定向后,浏览器的地址显示正确的URL,但页面内容为

您无权开启第是页面。 braindump:// rest_of_address_here

是否有需要设置的特定权限以允许此类行为?

按照common tasks应该是:

<scheme android:name="braindump" /> 
+0

似乎取决于你往哪里看http://developer.android.com/guide/topics/manifest/data-element.html – Cylindric 2010-06-30 11:25:26

我有完全相同的问题(的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] 

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

其实,这是可能的,只有一个活动做的,只是创造一个更意图过滤器。就像这样:

<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> 

我不认为这正是你的问题的原因,但我得到了同样的错误“您没有权限打开此页”,这是因为我使用的是方案用大写字母。例如“Celly”而不是“celly”。这在模拟器中正常工作,但在真实设备上失败。将其全部更改为小写固定它。

+1

同样的事情发生在我身上。我感到你的痛苦。得使用全部小写。 – AlcubierreDrive 2013-05-03 03:42:34