2

私は2つのAndroidアプリケーションを開発しています:

  • 1つ目は、ランチャーなどを備えた通常のアプリケーションです
  • もう 1 つはビューアー アクティビティのみのアプリケーションです (マニフェストを参照)。

    <activity
        android:name=".MyActivity"
        android:icon="@drawable/icon"
        android:label="@string/dropbox" >
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
    <activity
        android:name="com.dropbox.client2.android.AuthActivity"
        android:configChanges="orientation|keyboard"
        android:launchMode="singleTask" >
        <intent-filter>
            <data android:scheme="db-XXXXX" />
    
            <action android:name="android.intent.action.VIEW" />
    
            <category android:name="android.intent.category.BROWSABLE" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
    

計画では、最初のアプリケーションはインターネット アクセス許可を必要とせず、2 番目のアプリケーションは最初のアプリケーションへのアドオンのようなものです。

2 番目のアプリケーションは、ファイルを Dropbox と同期する必要があります (Sync API ではなく Core API を使用)。

最初のアプリから、次のように 2 番目のアプリから「MyActivity」を開始します。

    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setComponent(new ComponentName("my.package","my.package.MyActivity"));
    intent.putExtra("filePath", "/myFile.txt");
    startActivityForResult(intent, SYNC_REQUEST);

それはうまくいきます。アクティビティが表示され、まだ承認されていない場合、ユーザーはボタンを押す必要があります。次に、次のコードが実行されます

    AndroidAuthSession session = buildSession();
    mApi = new DropboxAPI<AndroidAuthSession>(session);

    mApi.getSession().startAuthentication(MyActivity.this);

ユーザーがドロップボックスをインストールしていない場合、ブラウザがポップアップします。

今、私の悩みが始まります:

ユーザーが「同意する」または「拒否する」を押すとすぐに、ブラウザーは消えません。開いたままになり、MyActivity は再開されません (onResume は呼び出されません!)。

私は知った、それを追加する

    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

最初のアプリケーションから MyActivity を開始する前に問題を解決しますが、MyActivity の結果をリッスン/待機することはできません。

私はイライラしています。誰かが私を助けたり、アドバイスをくれたりできますか?

ありがとう!

4

1 に答える 1