2013-04-28 5 views
1

У меня есть производственные и тестовые версии моего приложения. Единственное различие между ними - это имя пакета, так что оба могут быть установлены одновременно на одном устройстве.Приложение для Android не показано в Dropbox Chooser

Оба приложения имеют намерения фильтр, который связывает их со следующим типом файла андроида: MIMETYPE = "приложения/октет-поток" андроид: ". * \ Myfile" pathPattern =

Шаг 1. Я устанавливаю производственную версию и открываю файл в dropBox. РЕЗУЛЬТАТ ОК: моя версия появляется в меню Chooser.

Шаг 2. Я устанавливаю тестовую версию и открываю файл в dropBox. RESULT FAIL: в меню Chooser появляется только производственная версия.

Шаг 3. Я удаляю производственную версию и открываю файл в dropBox. РЕЗУЛЬТАТ ОК: в меню Chooser появляется только тест.

После шага 2, который я также проверил с некоторыми другими приложениями, но сравнение результатов может быть нецелесообразным, поскольку схема контента и mimeTypes различны.

Gmail OK (схема содержание "Содержание:", тип_mime является "применение/октет-поток")

Google Drive OK Схема (содержание "Файл:" , Mimetype является "приложение/vnd.my.custom.type")

Evernote FAIL (схема содержание «Содержание:», тип_mime является «применение/октет-поток»)

Evernote терпит неудачу, потому что Намерение создает дает ни правильные MIMETYPE, ни правильное расширение файла!

Ниже приведен все фильтры умысла я использую

 </intent-filter> 
     <!-- 
      Intent-filter for restoring via apps that use the file scheme, 
      and preserve the file-name, but not the MIME type, e.g. Dropbox. 
     --> 
     <intent-filter> 
      <action android:name="android.intent.action.VIEW" /> 

      <category android:name="android.intent.category.BROWSABLE" /> 
      <category android:name="android.intent.category.DEFAULT" /> 

      <data 
       android:host="*" 
       android:mimeType="application/octet-stream" 
       android:pathPattern=".*\\.wsctry" 
       android:scheme="file" /> 
     </intent-filter> 

     <!-- 
      Intent-filter for restoring via apps that use the content scheme, preserve 
      the MIME type, but not the file name. 
     --> 
     <intent-filter> 
      <action android:name="android.intent.action.VIEW" /> 

      <category android:name="android.intent.category.BROWSABLE" /> 
      <category android:name="android.intent.category.DEFAULT" /> 

      <data 
       android:host="*" 
       android:mimeType="application/vnd.winesecretary.com.backup" 
       android:scheme="content" /> 
      <!-- Some apps (e.g. some versions of Gmail) use the file suffix as the mimeType! --> 
      <data 
       android:host="*" 
       android:mimeType="application/wsctry" 
       android:scheme="content" /> 
     </intent-filter> 
     <!-- 
      Intent-filter for restoring via Google Drive and 
      other apps that use the file scheme and preserve the 
      MIME type. 
     --> 
     <intent-filter> 
      <action android:name="android.intent.action.VIEW" /> 

      <category android:name="android.intent.category.BROWSABLE" /> 
      <category android:name="android.intent.category.DEFAULT" /> 

      <data 
       android:host="*" 
       android:mimeType="application/vnd.winesecretary.com.backup" 
       android:scheme="file" /> 
     </intent-filter> 

     <!-- Special cases for some versions of Gmail --> 
     <intent-filter> 
      <action android:name="android.intent.action.VIEW" /> 

      <category android:name="android.intent.category.BROWSABLE" /> 
      <category android:name="android.intent.category.DEFAULT" /> 

      <!-- 
      Gmail uses some strange mimeTypes when opening WS backup attachments, 
      and none of them correspond to the original mimeType given by WS itself! 
      --> 
      <data 
       android:host="gmail-ls" 
       android:mimeType="application/octet-stream" 
       android:scheme="content" /> 
     </intent-filter> 
+0

Вы пробовали что-нибудь другое, чем DropBox? Например, вы создали свой собственный вызов 'startActivity()' и попробовали? Это поможет различать проблему с Android и проблему с DropBox. – CommonsWare

+0

Благодаря предложению CommonsWare, я создал простой вызов StartActivity(). Симптомы были не такими же, как у Dropbox, но это тоже не сработало. Поэтому я упростил фильтры намерений, и теперь работают как Dropbox, так и простой вызов StartActivity()! –

ответ

1

Проблема исчезла после того, как я упростил намерение фильтров.

Это то, что я использую сейчас

<!-- Intent-filter for Intents that contain the file suffix. --> 
<intent-filter> 
    <action android:name="android.intent.action.VIEW" /> 
    <category android:name="android.intent.category.BROWSABLE" /> 
    <category android:name="android.intent.category.DEFAULT" /> 

    <!-- For a path to be meaningful, both a scheme and an authority must be specified. --> 
    <data 
     android:mimeType="*/*" 
     android:host="*" 
     android:scheme="file" 
     android:pathPattern=".*\\.wsctry" /> 
</intent-filter> 

<!-- Intent-filter for Intents that contain a MIME type --> 
<intent-filter> 
    <action android:name="android.intent.action.VIEW" /> 
    <category android:name="android.intent.category.BROWSABLE" /> 
    <category android:name="android.intent.category.DEFAULT" /> 

    <!-- This is the original mimeType which was used when creating the file. --> 
    <data android:mimeType="application/vnd.winesecretary.com.backup" /> 

    <!-- Some apps (e.g. some versions of Gmail) use the file suffix as the mimeType! --> 
    <data android:mimeType="application/wsctry" /> 

    <!-- Gmail sometimes uses some strange mimeTypes when opening attachments --> 
    <data 
     android:host="gmail-ls" 
     android:mimeType="application/octet-stream" /> 
</intent-filter> 
+0

Thx, это работает очень хорошо! – bendaf

Смежные вопросы