2011-12-28 26 views
0

例如k9-Mail會嘗試找到一個應用程序來處理一些附件並使用電子郵件的MimeType-Specification。轉發意圖?

例如用PDF發送正確(調試信息):

12-27 15:41:58.992: I/ActivityManager(119): Starting: Intent { act=android.intent.action.VIEW dat=content://com.fsck.k9.attachmentprovider/01549957-459d-4ee3-b568-7e59390a9535/3/VIEW typ=application/pdf flg=0x3880001 cmp=com.adobe.reader/.AdobeReader } from pid 119 

但是,如果郵件附上PDF不Mime類型「應用程序/ PDF」,而是用「‘應用程序/ PDF’」它不工作。 :-(這導致廣播:

12-27 15:35:15.007: I/ActivityManager(119): Starting: Intent { act=android.intent.action.VIEW dat=content://com.fsck.k9.attachmentprovider/01549957-459d-4ee3-b568-7e59390a9535/2/VIEW typ='application/pdf' flg=0x80001 } from pid 3635 

的「在開頭和結尾導致恕我直言,沒有應用程序被發現,以處理:-(

K9郵件錯過了一些其他的映射,所以。我的想法是建立一個小應用程序,捕捉呼叫,並將它轉發,但例如,讀者可以不打開我試過:

@Override 
protected void onPostCreate(Bundle savedInstanceState) { 
    super.onPostCreate(savedInstanceState); 

    Log.i(TAG, "Activity is called and created"); 

    mapping.put("'application/pdf'", "application/pdf"); 
    String type = getIntent().getType(); 

    if (mapping.containsKey(type)) { 
     Log.i(TAG, "found mapping: " + type + " => " + mapping.get(type)); 

     Log.v(TAG, "Intent before: " + getIntent().toString()); 
     Intent i = new Intent(getIntent().getAction(), getIntent().getData()); 
     i.setType(mapping.get(type)); 
     i.setData(getIntent().getData()); 
     i.setFlags(getIntent().getFlags()); 

     Log.v(TAG, "Intent after: " + getIntent().toString()); 
     startActivity(i); 
    } 

    finish(); 
} 

@Override 
protected void onDestroy() { 
    super.onDestroy(); 
    Log.i(TAG, "Activity is destroyed"); 
} 

我覺得有什麼用「CMD」是錯誤的......因爲調試器顯示

12-28 08:38:51.445: V/ActivityForwardIntent(1195): Intent after: Intent { act=android.intent.action.VIEW dat=content://com.fsck.k9.attachmentprovider/01549957-459d-4ee3-b568-7e59390a9535/2/VIEW typ='application/pdf' flg=0x80001 cmp=de.blablupp.android.testproject/.ActivityForwardIntent } 

有人可以幫我嗎?是否有可能,PDF應用程序無法獲取內容?但我看不到PDF應用程序是可選或開始的。 :-(

的一個問題是也 - 拿什麼CMP和我怎麼可以把這個信息給新的意圖

我希望能解決這個問題,因爲它實在是煩人保存的內容和啓動?它與文件瀏覽器。

TIA和reagards

nauni

+0

簽名被刪除,請參考http://www.stackoverflow.com/faq#signatures – 2011-12-28 08:49:28

+0

的常見問題解答,您的「Intent after」日誌消息正在輸出錯誤信息。 getIntent()將獲得用於啓動您的Activity的Intent,而不是您以編程方式構建的意圖 – dstricks 2011-12-28 09:29:34

回答

0

現在,我看到我的錯......我是想了這麼多之後,盲人......

Log.v(TAG, "Intent after: " + getIntent().toString()); 

沒有登錄錯了對象:-(...

Log.v(TAG, "Intent after: " + i.toString()); 

做了正確的記錄,所以我發現這個問題,現在的應用程序嘗試啓動acrorad。所以這個問題解決了。謝謝!

問題是用一個命令設置數據和類型。因此,兩者都設置正確並啓動應用程序。設置第一個和下一個命令下一個將沒有成功。

i.setDataAndType(getIntent().getData(), mapping.get(getIntent().getType())); 

感謝您的關注,nauni

PS:但現在我有安全權限的問題......但首先我試圖找到一個解決方案之前,我問什麼。 ;-)