Question

I want to open a file in the phone, by the action in the watch...

The problem is:

Intent intent2 = new Intent();
intent2.setAction(android.content.Intent.ACTION_VIEW);
File file = new File("/sdcard/file.mp4");
intent2.setDataAndType(Uri.fromFile(file), "video/*");
startActivity(intent2); 

it says startActivity its not declared in the control extension.

I think I am missing something, maybe there is another method to send the intent to the phone?

Was it helpful?

Solution

The reason you can't just call startActivity() in your control extension is because you need a Context since ControlExtension is not derived from Activity. You can get a Context object from the Constructor for the Control and save it to a member variable then just call context.startActivity().

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top