2011-03-08 70 views
1

我正在通過創建一個應用程序來簡單地創建主屏幕快捷方式來讀取SD卡上的文件,從而允許android使用其默認應用程序打開它們,從而練習我的Android技能。ANDROID:Image Shortcut導致圖庫重建相冊

一切都很好,工作,但是當我創建一個快捷方式到的圖像會發生以下情況

  1. 畫廊展示了幾秒鐘的
  2. 吐司消失「加載新的相冊和照片」吐司秒
  3. 吐司重新出現幾秒
  4. 照片終於顯示。

我也應該注意到,通過另一個文件管理器打開文件時,庫不顯示任何這些祝酒詞的,但它也確實表現出低分辨率緩衝的圖像外觀半秒,顯示高分辨率的一個前。還要注意,這種行爲在多個文件\類型中很明顯(無論如何都試過jpegs和png)。

這是我的快捷方式本身的意圖(路徑顯然是路徑+文件名的字符串):

Intent shortcutIntent = new Intent(); 
shortcutIntent.setAction(android.content.Intent.ACTION_VIEW); 
File file = new File(path); 
Uri uri = Uri.fromFile(file); 
MimeTypeMap map = MimeTypeMap.getSingleton(); 
String mime = map.getMimeTypeFromExtension(MimeTypeMap.getFileExtensionFromUrl(uri.toString().toLowerCase())); 
shortcutIntent.setDataAndType(uri, mime); 

在打開的快捷logcat的告訴我:

03-08 19:34:16.431: INFO/ActivityManager(167): Starting: Intent { act=android.intent.action.VIEW dat=file:///sdcard/download/TIMETABLE.png typ=image/png flg=0x14000000 cmp=com.cooliris.media/.Gallery bnds=[15,159][144,269] } from pid 262 
03-08 19:34:16.480: INFO/Gallery(1440): onDestroy 
03-08 19:34:16.511: INFO/Gallery(1440): onCreate 
03-08 19:34:16.621: DEBUG/CacheService(1440): Refreshing Cache for all items 
03-08 19:34:16.621: INFO/CacheService(1440): Refreshing cache. 
03-08 19:34:16.721: INFO/CacheService(1440): Building albums. 
03-08 19:34:16.791: INFO/RenderView(1440): First Draw 
03-08 19:34:16.831: INFO/CacheService(1440): Done building albums. 
03-08 19:34:16.831: INFO/CacheService(1440): Building items. 
03-08 19:34:16.971: INFO/ActivityManager(167): Displayed com.cooliris.media/.Gallery: +498ms 
03-08 19:34:17.001: INFO/CacheService(1440): Done building items. 
03-08 19:34:17.011: INFO/MediaFeed(1440): Replacing media set 310386146 
03-08 19:34:17.011: INFO/MediaFeed(1440): Replacing media set 1506676782 
03-08 19:34:17.011: INFO/MediaFeed(1440): Replacing media set -1928128949 
03-08 19:34:17.171: DEBUG/dalvikvm(167): GC_EXPLICIT freed 690K, 41% free 5902K/9991K, external 1612K/2124K, paused 109ms 
03-08 19:34:17.361: DEBUG/dalvikvm(1083): GC_EXPLICIT freed 175K, 52% free 2678K/5575K, external 0K/0K, paused 35ms 
03-08 19:34:18.521: DEBUG/AlarmManagerService(167): Kernel timezone updated to -660 minutes west of GMT 
03-08 19:34:18.531: DEBUG/SystemClock(275): Setting time of day to sec=1299573259 
03-08 19:34:26.127: ERROR/(1440): Not JPEG: /sdcard/download/TIMETABLE.png 
03-08 19:34:26.138: DEBUG/CacheService(1440): Refreshing Cache for all items 
03-08 19:34:26.138: INFO/CacheService(1440): Refreshing cache. 
03-08 19:34:26.197: INFO/CacheService(1440): Building albums. 
03-08 19:34:26.258: INFO/CacheService(1440): Done building albums. 
03-08 19:34:26.258: INFO/CacheService(1440): Building items. 
03-08 19:34:26.348: INFO/CacheService(1440): Done building items. 
03-08 19:34:26.348: DEBUG/CacheService(1440): No items found for album 
03-08 19:34:26.348: INFO/GridLayer(1440): Slot changing from -1 to -1 
03-08 19:34:26.358: INFO/RenderView(1440): Texture creation fail, glError 1281 
03-08 19:34:26.388: WARN/MediaProvider(1083): original media doesn't exist or it's canceled. 
03-08 19:34:26.388: INFO/CacheService(1440): Built thumbnail and screennail for 0 in 33 

這是相同的快捷方式到JPEG除了沒有

ERROR/(1440): Not JPEG: /sdcard/download/TIMETABLE.png 

線。奇怪的是,這個錯誤仍然出現,但畫廊可以並將打開PNG。

其他一切似乎都很好(即pdf,音頻,視頻,文件等等)。

反正任何幫助將是非常有益的,

乾杯, 山姆

回答

2

問題解決了!

備查,需要指向 MNT/SD卡/ ... 不 /SD卡/ ...

很奇怪的是,它仍然有效,但畫廊迷糊。

+0

在我的情況下,這個問題沒有得到解決,但在畫廊應用程序提供了一個「停止意外」強制關閉屏幕。我正在使用「file:/// mnt/sdcard ...」,這是它適用於我的LG Optimus手機的唯一方式。在模擬器上,無論我嘗試什麼,它都會顯示所有可用圖片的圖庫應用程序。我討厭這種分裂.. – kellogs 2011-09-26 22:42:15