geekyhawkes
Lurker
I am launching some MP4 videos from within my application using the following INTENT (in activity B):
if (v == image5) {
File file = new File(Environment.getExternalStorageDirectory()
+ "/.intro/Resources/Res5.mp4");
if (file.exists()) {
Uri path = Uri.fromFile(file);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(path, "video/mp4");
//intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
try {
startActivity(intent);
overridePendingTransition(R.anim.zoom_enter,
R.anim.zoom_exit);
} catch (ActivityNotFoundException e) {
}
}
}
When the video completes I would like android to return to the activity that launched the intent (Activity B), but it doesnt, instead it shows the launcher activity for my app (Activity A). I have tried `FLAG_ACTIVITY_NEW_TASK` but this made no difference.
Full Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.my.app.trainer"
android:installLocation="preferExternal"
android:versionCode="14"
android:versionName="1.1" >
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="16" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.SET_WALLPAPER" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
<uses-permission android:name="com.android.launcher.permission.UNINSTALL_SHORTCUT" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:largeHeap="true"
android:theme="@style/AppTheme" >
<activity
android:name=".SplashScreen"
android:label="@string/title_activity_splash_screen"
android:screenOrientation="landscape" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
<!-- this is activity A -->
android:name=".Main"
android:label="@string/title_activity_main"
android:screenOrientation="landscape" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<!-- <category android:name="android.intent.category.LAUNCHER" /> -->
</intent-filter>
</activity>
<activity
android:name=".Main3"
android:label="@string/title_activity_main3"
android
arentActivityName=".Main"
android:screenOrientation="landscape" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.my.app.trainer.Main" />
</activity>
<activity
android:name=".CNAChooser"
android:label="@string/title_activity_cnachooser"
android
arentActivityName=".Main3" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.my.app.trainer.Main3" />
</activity>
<activity
<!-- this is activity B -->
android:name=".CNARes"
android:label="@string/title_activity_cnares"
android
arentActivityName=".CNAChooser" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.my.app.trainer.CNAChooser" />
</activity>
</application>
</manifest>
How do I set the launching activity INTENT to ensure that when the video completes Activity B is shown?
When I select the imagebutton for the video to play (with defaults reset for which video application to use) then Activity A displays behind the dialog asking which app to play the video with.
Question 2: Why does the intent listed above launch activity A?
I have tried removing and re-installing the app, but the behavior is the same.
I have checked the developer options, "Don't keep activities" is not enabled.
I have installed the APK on 2 different android tablets and my S4 and the behavior is the same on all devices. I also tried with a full clean and refresh from Eclipse.
I have tried removing the animation and also tried FLAG_ACTIVITY_PREVIOUS_IS_TOP and still get the same behavior. I have also tried changing the intent to launch a PDF file using code that I know works from my Activity A (main) class file. I am really confused what is going on here.
Thanks;
Andy
if (v == image5) {
File file = new File(Environment.getExternalStorageDirectory()
+ "/.intro/Resources/Res5.mp4");
if (file.exists()) {
Uri path = Uri.fromFile(file);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(path, "video/mp4");
//intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
try {
startActivity(intent);
overridePendingTransition(R.anim.zoom_enter,
R.anim.zoom_exit);
} catch (ActivityNotFoundException e) {
}
}
}
When the video completes I would like android to return to the activity that launched the intent (Activity B), but it doesnt, instead it shows the launcher activity for my app (Activity A). I have tried `FLAG_ACTIVITY_NEW_TASK` but this made no difference.
Full Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.my.app.trainer"
android:installLocation="preferExternal"
android:versionCode="14"
android:versionName="1.1" >
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="16" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.SET_WALLPAPER" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
<uses-permission android:name="com.android.launcher.permission.UNINSTALL_SHORTCUT" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:largeHeap="true"
android:theme="@style/AppTheme" >
<activity
android:name=".SplashScreen"
android:label="@string/title_activity_splash_screen"
android:screenOrientation="landscape" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
<!-- this is activity A -->
android:name=".Main"
android:label="@string/title_activity_main"
android:screenOrientation="landscape" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<!-- <category android:name="android.intent.category.LAUNCHER" /> -->
</intent-filter>
</activity>
<activity
android:name=".Main3"
android:label="@string/title_activity_main3"
android
arentActivityName=".Main"android:screenOrientation="landscape" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.my.app.trainer.Main" />
</activity>
<activity
android:name=".CNAChooser"
android:label="@string/title_activity_cnachooser"
android
arentActivityName=".Main3" ><meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.my.app.trainer.Main3" />
</activity>
<activity
<!-- this is activity B -->
android:name=".CNARes"
android:label="@string/title_activity_cnares"
android
arentActivityName=".CNAChooser" ><meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.my.app.trainer.CNAChooser" />
</activity>
</application>
</manifest>
How do I set the launching activity INTENT to ensure that when the video completes Activity B is shown?
When I select the imagebutton for the video to play (with defaults reset for which video application to use) then Activity A displays behind the dialog asking which app to play the video with.
Question 2: Why does the intent listed above launch activity A?
I have tried removing and re-installing the app, but the behavior is the same.
I have checked the developer options, "Don't keep activities" is not enabled.
I have installed the APK on 2 different android tablets and my S4 and the behavior is the same on all devices. I also tried with a full clean and refresh from Eclipse.
I have tried removing the animation and also tried FLAG_ACTIVITY_PREVIOUS_IS_TOP and still get the same behavior. I have also tried changing the intent to launch a PDF file using code that I know works from my Activity A (main) class file. I am really confused what is going on here.
Thanks;
Andy