(作業コード用に更新された投稿)
私は自分のAndroidアプリにTwitterで認証を取得させてから、アプリのコールバックURLで認証トークンを取得しようとしています。
ただし、AndroidManifest.xmlに問題があると思います。私が理解していることから、android:launchmode = "singleTask"を使用してアプリを起動する場合は、メインアクティビティのonResume()メソッドでAccessTokenオブジェクトを取得する必要があります。
singleTaskの起動を指定しない場合は、代わりにonNewIntent()メソッドで取得を行う必要があります。
マニフェストファイルで両方の方法を試しましたが、onNewIntent()またはonResume()で制御できません。TwitterはコールバックURLを使用してリダイレクトしますが、Webブラウザは「Webページは利用できません」とだけ表示します。そしてlogcatは言う:
Tab E onReceivedError -10 myapp://www.authtoke.app?oauth_token=2Y3jZMfHZ06Teezzy3l1KvlWqs961tsqXFlTgMHrA&oauth_verifier=PBfCueZLEzEteBoLTksDARQDRi3raVi5FiEJllCYus The protocol is not supported.
誰かが私がだまされたものを知っていますか?マニフェストエントリは次のとおりです。
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.test.twitterLib"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="4" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<application android:name=".myAppVars" android:icon="@drawable/ic_launcher" android:label="@string/app_name" >
<activity android:name=".TwitterLibActivity" android:label="@string/app_name" android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" > </action>
<category android:name="android.intent.category.LAUNCHER" ></category>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" > </action>
<category android:name="android.intent.category.DEFAULT" ></category>
<category android:name="android.intent.category.BROWSABLE" > </category>
<data android:scheme="myapp" android:host="www.authtoke.app"> </data>
</intent-filter>
</activity>
</application>
</manifest>