0

I have an appwidget that launches a video. It works on all my older devices and even my 4.1 emulator, but does not work on my target device with is the Nexus 7. On the older devices, including an S2, when you tap the widget the video plays. On the Nexus 7 the widget gets highlighted but then nothing triggers.

The code within the configuration activity that creates the intent is pretty simple:

Intent videoIntent = new Intent(Intent.ACTION_VIEW);
videoIntent.setDataAndType(Uri.parse(selectedPath), "video/*");
PendingIntent pendingIntent = PendingIntent.getActivity(getBaseContext(), 0,    videoIntent, PendingIntent.FLAG_UPDATE_CURRENT);

RemoteViews views = new RemoteViews(getBaseContext().getPackageName(), R.layout.widgetlayout);
views.setImageViewBitmap(R.id.widgetButton, thumbnail);
views.setOnClickPendingIntent(R.id.widgetButton, pendingIntent);

I can't seem to find any more device-agnostic method for starting the video than Intent.ACTION_VIEW.

Any ideas?

vanstrien
  • 33
  • 1
  • 3
  • What happens when you replace `video/*` with the correct MIME type? And why are you using `getBaseContext()` instead of an appropriately-scoped `this`? – CommonsWare Sep 25 '12 at 12:08
  • any stacktrace, logcat, information whatsoever? – njzk2 Sep 25 '12 at 12:08
  • CommonsWare: `video/*` is the correct MIME type, isn't it? I think I picked up the `getBasecontext()` from some code snippets. I've replaced it with a `(context) this`. It still doesn't work on the Nexus. I can play the video fine from the Gallery using the standard video player. I've confirmed that the changes haven't correct the problem on the Nexus 7 but that the widget works fine still on my other devices. The help is much appreciated though. Please let me know if you have any other thoughts. – vanstrien Sep 25 '12 at 22:01
  • njzk2: There is no error message in the logs. I can't see anything relevant. There is a general error that I don't think is related to my widget. `09-25 20:14:38.930: E/ActivityThread(518): Activity com.android.internal.app.ChooserActivity has leaked IntentReceiver com.android.internal.app.ResolverActivity$1@40f837a0 that was originally registered here. Are you missing a call to unregisterReceiver()?` – vanstrien Sep 25 '12 at 22:02
  • Any ideas folks? The intent still works fine on my S2 and Tf700. It is only the Nexus 7 that doesn't play nice. My intent code reads: – vanstrien Oct 01 '12 at 00:07
  • `Intent videoIntent = new Intent(Intent.ACTION_VIEW); videoIntent.setDataAndType(Uri.parse(selectedPath), "video/*"); PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, videoIntent, PendingIntent.FLAG_UPDATE_CURRENT); ` – vanstrien Oct 01 '12 at 00:08

1 Answers1

0

I found the answer. This is probably for anything running Android 4.1.1, although I didn't need to do this for my emulator running 4.1

My original code was:

Intent videoIntent = new Intent(Intent.ACTION_VIEW);
videoIntent.setDataAndType(Uri.parse(selectedPath), "video/*");
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, videoIntent, PendingIntent.FLAG_UPDATE_CURRENT);

However for some reason I have to use File() and Uri.fromFile.

Intent videoIntent = new Intent(Intent.ACTION_VIEW);
File file = new File(selectedPath);
videoIntent.setDataAndType(Uri.fromFile(file), "video/mp4");
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, videoIntent, PendingIntent.FLAG_UPDATE_CURRENT);
vanstrien
  • 33
  • 1
  • 3