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?

有帮助吗?

解决方案

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().

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top