Custom scheme doesn't seem to launch in the app intent

前端 未结 4 1133
梦毁少年i
梦毁少年i 2021-02-06 15:54

I\'m trying to create an Android app that needs to use OAuth to authenticate (with the Google Wave data API)

I\'ve specified a custom scheme in my AndroidManifest.

相关标签:
4条回答
  • 2021-02-06 16:24

    I had the exact same problem (OAuth) and this is how I fixed it.

    I've separated my Main from the class that will act on the URI.

    Here's how the AndroidManifest.xml should look like:

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

    And I was able to open URIs like myscheme//oauth?oauth_verifier=xxx&oauth_token=yyy

    0 讨论(0)
  • 2021-02-06 16:24

    Actually, it's possible to do it with only one activity, just creating one more intent filter. Like this:

    <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>
    
    0 讨论(0)
  • 2021-02-06 16:29

    According to the common tasks that should be:

    <scheme android:name="braindump" />
    
    0 讨论(0)
  • 2021-02-06 16:41

    I don't think this is exactly the cause of your problem, but I got this same error "You do not have permission to open this page" and it was because I was using a scheme with a capital letter. eg "Celly" instead of "celly". This worked fine in the emulator but failed on real devices. Changing it all to lowercase fixed it.

    0 讨论(0)
提交回复
热议问题