I created my own application for the media player and installed it on the device. I created another application that has one button, As soon as I press the button. I have to give an option in which the player should play the video.
My media player application manifest file:
<application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/NoActionBar" > <activity android:name="com.example.player.MainPlayerActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="rtsp" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="http" /> <data android:scheme="https" /> <data android:scheme="content" /> <data android:scheme="file" /> <data android:mimeType="video/mpeg4" /> <data android:mimeType="video/mp4" /> <data android:mimeType="video/3gp" /> <data android:mimeType="video/3gpp" /> <data android:mimeType="video/3gpp2" /> <data android:mimeType="video/webm" /> <data android:mimeType="video/avi" /> <data android:mimeType="application/sdp" /> <data android:mimeType="video/x-ms-wmv" /> <data android:mimeType="video/x-msvideo" /> <data android:mimeType="video/mpeg" /> </intent-filter> <intent-filter> !-- HTTP live support --> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="http" /> <data android:mimeType="audio/x-mpegurl" /> <data android:mimeType="audio/mpegurl" /> <data android:mimeType="application/vnd.apple.mpegurl" /> <data android:mimeType="application/x-mpegurl" /> </intent-filter> </activity> </application>
Example code for raising intent:
public class MainActivityHsl extends Activity { private String url = "/sdcard/vid.mp4"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main_activity_hsl); Button button = (Button) findViewById(R.id.button1); button.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { playVideo(MainActivityHsl.this, Uri.parse("/sdcard/vid.mp4"), "SUKESH"); } }); } public void playVideo(Activity activity, Uri uri, String title) { Intent intent = new Intent(Intent.ACTION_VIEW) .setDataAndType(uri, "video/mp4"); intent.putExtra(Intent.EXTRA_TITLE, title); activity.startActivity(intent); }}
Logcat:
E / AndroidRuntime (1552): android.content.ActivityNotFoundException: no activity to handle Intent {act = android.intent.action.VIEW dat = / sdcard / vid.mp4 typ = video / mp4 (there are additional functions)} E / AndroidRuntime (1552): at android.app.Instrumentation.checkStartActivityResult (Instrumentation.java:1512) E / AndroidRuntime (1552): at android.app.Instrumentation.execStartActivity (Instrumentation.java:1384) E / AndroidRuntime (1552): at android .app.Activity.startActivityForResult (Activity.java:3190) E / AndroidRuntime (1552): at android.app.Activity.startActivity (Activity.java:3297) E / AndroidRuntime (1552): on com.example.videohsltest.MainActivityHsl .playVideo (MainActivityHsl.java:54) E / AndroidRuntime (1552): at com.example.videohsltest.MainActivityHsl $ 1.onClick (MainActivityHsl.java:30) E / AndroidRuntime (1552): at android.view.View.performClick ( View.java:3511) E / AndroidRuntime (1552): on android.view.View.onKeyUp (View.java:6073) E / AndroidRuntime (1552): on android.widget.TextView.onKeyUp (TextView.java:5586) E / AndroidRuntime (1552): on android.view.KeyEvent.dispatch (KeyEvent.java:2575) E / AndroidRuntime (1552): on android.view.View.dispatchKeyEvent (View.java∗500) E / AndroidRuntime (1552): in android.view.ViewGroup.dispatchKeyEvent (ViewGroup.java:1246) E / AndroidRuntime (1552): in android.view.ViewGroup. dispatchKeyEvent (ViewGroup.java:1246) E / AndroidRuntime (1552): in android.view.ViewGroup.dispatchKeyEvent (ViewGroup.java:1246) E / AndroidRuntime (1552): in android.view.ViewGroup.dispatchKeyEvent (ViewGroup.java: 1246) E / AndroidRuntime (1552): at com.android.internal.policy.impl.PhoneWindow $ DecorView.superDispatchKeyEvent (PhoneWindow.java:1879) E / AndroidRuntime (1552): at com.android.internal.policy.impl. PhoneWindow.superDispatchKeyEvent (PhoneWindow.java:1361) E / AndroidRuntime (1552): at android.app.Activity.dispatchKeyEvent (Activity.java:2324) E / AndroidRuntime (1552): at com.android.internal.policy.impl. Phonewin dow $ DecorView.dispatchKeyEvent (PhoneWindow.java:1806) E / AndroidRuntime (1552): on android.view.ViewRootImpl.deliverKeyEventPostIme (ViewRootImpl.java{327) E / AndroidRuntime (1552): on android.view.ViewRootImpl.handlein ViewRootImpl.java:3300) E / AndroidRuntime (1552): at android.view.ViewRootImpl.handleMessage (ViewRootImpl.java:2460) E / AndroidRuntime (1552): at android.os.Handler.dispatchMessage (Handler.java:99) E / AndroidRuntime (1552): at android.os.Looper.loop (Looper.java:137) E / AndroidRuntime (1552): at android.app.ActivityThread.main (ActivityThread.java:4424) E / AndroidRuntime (1552) : in java.lang.reflect.Method.invokeNative (native method) E / AndroidRuntime (1552): in java.lang.reflect.Method.invoke (Method.java∗11) E / AndroidRuntime (1552): at com.android .internal.os.ZygoteInit $ MethodAndArgsCaller.run (ZygoteInit.java:784) E / AndroidRuntime (1552): on com.android.internal.os.ZygoteInit.main (ZygoteInit.javahaps51) E / AndroidRuntime (1552): at dalvik.s ystem.NativeStart.main (native method) W / ActivityManager (203): force shutdown com.example.videohsltest / .MainActivityHsl
Can someone help me with this, I will not be able to start the full action using the dialog box. What is the reason for this. Thanks at Advance.
source share