i trying create test app launch intents of different player application within.
tried this:
intent intent = new intent(); intent.setaction(android.content.intent.action_view); file file = new file("/sdcard/1234.mp4"); intent.setdataandtype(uri.fromfile(file), "video/*"); intent.addflags(intent.flag_grant_read_uri_permission); intent.setclassname("com.android.gallery3d","com.android.gallery3d.app.movieactivity"); startactivityforresult(intent, on_completion); i understand startactivityforresult() trigger callback once launched intent has finished job. expected in onactivityresult() implementation receiving completion notification.
protected void onactivityresult(int requestcode, int resultcode, intent data) { super.onactivityresult(requestcode, resultcode, data); log.i(tag,"onactivityresult resultcode " + resultcode + "requestcode" + requestcode); }
but, question getting resultcode "zero" i.e. resultcode = result_canceled if playback successful or if specify invalid file name while launching intent.
here manifest file:
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.rtcdemo" android:versioncode="1" android:versionname="1.0" > <uses-sdk android:minsdkversion="8" android:targetsdkversion="19" /> <application android:allowbackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/apptheme" > <activity android:name="com.example.rtcdemo.mainactivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity> </application> </manifest> here questions:
1. how can handle better oncompletion event ? i.e return state of launched intent, whether playback successful or fail.
2. if not right way implement, can please guide me right set of tutorial can sample code ?
my objective launch intents of multiple media player app gallery, mx player , vlc , know whether playback of file successful or not clip specified.
i newbie , suggestions on topic more helpful.
as written in android developer on activities
in other protocols (such action_main or action_view), may not result when expect.
you can't count on action views returning expect,so did implement custom alert dialog shows possible applications can open file,a modified version shown here custom intent chooser
update
after little more search found that, can see various of classes, important thing class calling intent doesn't changing return value.
calling movieactivity extends activity not activitystate.
in abstract class activitystate value changing , returns. maybe problem.
Comments
Post a Comment