Domanda

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?

È stato utile?

Soluzione

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top