What is the purpose of trying to send that Intent? If you are just trying to activate the Vibration, there is already a method built into the utilities class to do this. Take a look at the ControlExtension.startVibrator() method in the SmartExtensionUtils project.
How to use a intent in android?
-
09-07-2023 - |
سؤال
I have a sony smart watch and i'm trying to invoke a vibration intent by using the following:
Intent intentImplicit = new Intent(Control.Intents.CONTROL_VIBRATE_INTENT);
startActivity(intentImplicit);
it says startActivity its not declared in the control extension. How can I fix this? I found this online "You can get a Context object from the Constructor for the Control and save it to a member variable then just call context.startActivity()." but i'm unsure on how to do this
المحلول 2
نصائح أخرى
The Sony SDK documentation says you should use sendBroadcast()
See: http://developer.sonymobile.com/reference/sony-addon-sdk/com/sonyericsson/extras/liveware/aef/control/Control.Intents#CONTROL_VIBRATE_INTENT
So this should work:
context.sendBroadcast(intentImplicit, Registration.HOSTAPP_PERMISSION);
If you used a sample application from Sony as base, the context is already saved as a field of your class. If not, you can get a reference in the constructor of the Extension and save it to a field like this:
public class TestExtension extends ControlExtension
{
private Context context;
TestExtension(final String hostAppPackageName, final Context context, Handler handler)
{
super(context, hostAppPackageName);
this.context = context;
}
}