Reputation: 1254
private void setActionViewListener(final String uri) {
mediaButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(uri)));
}
});
}
The code above is used to start the browser with a given URL. The URL contains either a link to a sound file (mp3) or a video file (mp4). The code works on multiple devices. But we have problems on a HTC Desire (Android v 2.2) and on a Samsung Galaxy Nexus (Android v 4.0). On these devices the browser just flashes up and gets hidden again. So obviously the intent is broadcasted and received but somehow the ActivityManager moves the new browser activity to background.
Logcat shows the following Information (watch bold lines):
12-13 14:12:02.089: DEBUG/SurfaceFlinger(96): Layer::requestBuffer(this=0x71e430), index=0, pid=3369, w=480, h=90 success
**12-13 14:12:02.109: INFO/ActivityManager(96): Starting activity: Intent { act=android.intent.action.VIEW dat=http://<hostname>/StaticContent/<movie>.mp4 typ=video/mp4 cmp=android/com.android.internal.app.ResolverActivity }**
12-13 14:12:02.119: DEBUG/webkit-timers(3369): [JWebCoreJavaBridge::pause] >> do pause
12-13 14:12:02.119: DEBUG/webviewglue(3369): nativeDestroy view: 0xb59150
**12-13 14:12:02.119: INFO/ActivityManager(96): moveTaskToBack: 67**
12-13 14:12:02.129: DEBUG/SurfaceFlinger(96): Layer::setBuffers(this=0x9032e8), pid=6155, w=480, h=800
Does anyone see the problem?
Upvotes: 3
Views: 1559
Reputation: 2999
set this flag for the new intent
yourIntent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
yourIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Upvotes: 3