문제

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