2010-12-15 6 views
0

J'essaie de lancer une intention à partir de mon application qui va lire l'audio à partir d'un serveur de streaming. J'ai une URL pour ce flux et j'utilise bit.ly pour simplifier l'URL pour lancer (je l'ai essayé sans bit.ly et ont les mêmes résultats)Impossible de lancer le lien audio à partir de l'application Android

intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://bit.ly/gKltQE")); 
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // i tried with and without this, no luck 
startActivity(intent); 

Le navigateur commence, les charges le lien bit.ly, redirige vers le lien audio ferme ensuite et retourne à mon application

12-15 14:27:58.559 1259 8370 I ActivityManager: Starting activity: Intent { act=android.intent.action.VIEW dat=http://bit.ly/gKltQE flg=0x10000000 cmp=com.android.browser/.BrowserActivity (has extras) } 
12-15 14:14:23.903 1259 1383 I ActivityManager: Starting activity: Intent { act=android.intent.action.VIEW cat=[android.intent.category.BROWSABLE] dat=http://216.235.81.102:15532/play?now=65&membername;=&session=kxlu1:0&tag=live365&s=kxlu1&d=live365&r=0&app_id=live365:BROWSER%28pro%29 cmp=com.android.browser/.BrowserActivity } 
12-15 14:14:24.387 8848 8848 D webviewglue: nativeDestroy view: 0x3bb018 
12-15 14:14:24.387 1259 1600 I ActivityManager: Starting activity: Intent { act=android.intent.action.VIEW dat=http://216.235.81.102:15532/play?now=65&membername;=&session=kxlu1:0&tag=live365&s=kxlu1&d=live365&r=0&app_id=live365:BROWSER%28pro%29 typ=audio/mpeg cmp=com.android.music/.StreamStarter } 
12-15 14:14:24.387 1259 1929 I ActivityManager: moveTaskToBack: 12 

Quand je lance le même lien bit.ly dans le navigateur manuellement, il fonctionne très bien (lance l'application de streaming audio) :

12-15 14:26:21.403 8848 8848 D SearchDialog: launching Intent { act=android.intent.action.VIEW dat=http://bit.ly/gKltQE flg=0x10000000 cmp=com.android.browser/.BrowserActivity (has extras) } 
12-15 14:26:21.411 8848 8848 I SearchDialog: Starting (as ourselves) http://bit.ly/gKltQE#Intent;action=android.intent.action.VIEW;launchFlags=0x10000000;component=com.android.browser/.BrowserActivity;S.query=http%3A%2F%2Fbit.ly%2FgKltQE;S.user_query=bit;end 
12-15 14:26:21.411 1259 1259 I ActivityManager: Starting activity: Intent { act=android.intent.action.VIEW dat=http://bit.ly/gKltQE flg=0x10000000 cmp=com.android.browser/.BrowserActivity (has extras) }12-15 14:26:21.879 1259 1267 V DeviceStorageMonitorService: freeMemory=6210887680 
12-15 14:26:21.879 1259 1267 V DeviceStorageMonitorService: Threshold Percentage=10 
12-15 14:26:21.879 1259 1267 V DeviceStorageMonitorService: mTotalMemory = 70264913 
12-15 14:26:21.879 1259 1267 I DeviceStorageMonitorService: Posting Message again 
12-15 14:26:21.997 8848 8864 D dalvikvm: GC_FOR_MALLOC freed 14790 objects/467656 bytes in 85ms 
12-15 14:26:22.192 1259 1436 D dalvikvm: GC_FOR_MALLOC freed 47823 objects/2142584 bytes in 154ms 
12-15 14:26:22.208 1259 1263 I ActivityManager: Starting activity: Intent { act=android.intent.action.VIEW cat=[android.intent.category.BROWSABLE] dat=http://216.235.81.102:15532/play?now=65&membername;=&session=kxlu1:0&tag=live365&s=kxlu1&d=live365&r=0&app_id=live365:BROWSER%28pro%29 cmp=com.android.browser/.BrowserActivity } 
12-15 14:26:22.676 1259 1259 I ActivityManager: Starting activity: Intent { act=android.intent.action.VIEW dat=http://216.235.81.102:15532/play?now=65&membername;=&session=kxlu1:0&tag=live365&s=kxlu1&d=live365&r=0&app_id=live365:BROWSER%28pro%29 typ=audio/mpeg cmp=com.android.music/.StreamStarter } 
12-15 14:26:22.770 1259 8719 I AudioService: Remote Control registerMediaButtonEventReceiver() for ComponentInfo{com.android.music/com.android.music.MediaButtonIntentReceiver} 
12-15 14:26:22.801 8217 8217 V MediaPlaybackService: reloadQueue end 
12-15 14:26:22.809 8217 8217 V MediaPlaybackService: onCreate end 
12-15 14:26:22.809 8217 8217 V MediaPlaybackService: onStartCommand end 

J'ai essayé de jouer avec divers paramètres de intent.setFlags mais en vain. Peut-être un problème d'autorisations? Ou quelque chose à faire avec comment j'appelle startActivity?

Répondre

3

Il ne s'agit pas d'un problème d'autorisations, mais de la fin prématurée de BrowserActivity, peut-être parce qu'il n'y a pas d'onglet en cours. La meilleure chose à faire est de donner un indice supplémentaire pour résolveur intention que ce n'est pas en fait le navigateur qui devrait être la manipulation des données:

intent.setType("audio/mpeg"); 

Aucun autre drapeaux sont nécessaires ... Sound Player (ou votre lecteur multimédia de choix) va maintenant le gérer.

+0

Ah, merci pour l'indice. Cela ne l'a pas vraiment fait, mais cela m'a orienté dans la bonne direction ... J'ai dû appeler intention = new Intent (Intent.ACTION_VIEW); intention.addCatégorie (Intent.CATEGORY_DEFAULT); intent.setDataAndType (uriObj, mimeType); Quelque chose à propos de l'appel "setDataAndType" semble être nécessaire. Tellement étrange. – Eric

Questions connexes