我按照教程从手机调用可穿戴活动,发布在这里如何从掌上电脑发送通知到穿戴打开活动穿戴设备.但是,我从答案中获取源代码.但是,我无法让它运行.看起来好像onDataChanged()从未被调用过.我问这个问题本身就是一个问题,因为看起来这个例子适用于其他人.我在使用KitKat 4.4.2,如果这很重要的话.
任何提示在哪里检查,谢谢.
这是一个跟进问题... Android Wear捆绑通知和背景图像
我想创建一个Android Wear GridViewPager布局,当新的推送通知进入时,它会被创建.
下面是我的代码,当新消息进入时初始化GoogleApiClient连接,然后我可以将数据发送到Wear应用程序,然后创建GridView寻呼机.
我的问题是GoogleApiClient永远不会得到连接.我已成功运行sdk文件夹中的SynchonizedNotifications示例应用程序,因此我知道我的设备和手表已正确配对.
以下是当前代码......
public class GCMIntentService extends IntentService implements GoogleApiClient.ConnectionCallbacks,
GoogleApiClient.OnConnectionFailedListener{
@Override
protected void onHandleIntent(Context context, Intent intent) {
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addApi(Wearable.API)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
ConnectionResult connectionResult = mGoogleApiClient.blockingConnect(30, TimeUnit.SECONDS);
// Extract the payload from the message
Bundle extras = intent.getExtras();
if (this.mGoogleApiClient.isConnected()) {
// sending a simple message works
MessageApi.SendMessageResult result = Wearable.MessageApi.sendMessage(mGoogleApiClient,
node.getId(), "path", null).await();
PutDataMapRequest putDataMapRequest = PutDataMapRequest.create(Constants.BOTH_PATH);
putDataMapRequest.getDataMap().putString(Constants.KEY_CONTENT, "content");
putDataMapRequest.getDataMap().putString(Constants.KEY_TITLE, "title");
PutDataRequest request = putDataMapRequest.asPutDataRequest();
// push data …Run Code Online (Sandbox Code Playgroud) 我正在从Android手持设备向android服装设备发送通知.我想在android设备上添加一个启动活动的通知操作.
如何将待处理意图设置为磨损设备上的活动?如果在可穿戴设备上创建通知,我可以启动活动,但如果通知是在手机上创建然后发送到可穿戴设备,则无法启动.
// creating action for push notification created on handheld
public NotificationCompat.Action CreateWearAppAction(Integer metricId) {
// I wasnt able to look up the wear's main activity class since this is in the handheld project.
Intent wearPageIntent = new Intent(Intent.ACTION_VIEW);
Uri wearUri = Uri.parse("mywearapp://Test?MetricId=" + metricId);
wearPageIntent.setData(wearUri);
PendingIntent wearPagePendingIntent = PendingIntent.getActivity(context, 0, wearPageIntent, 0);
return new NotificationCompat.Action.Builder(R.drawable.ic_action_metric,
"Open Charts on Wear", wearPagePendingIntent)
.build();
}
Run Code Online (Sandbox Code Playgroud)
我正在尝试推出的磨损应用程序的活动清单:
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:noHistory="true"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<!-- deep …Run Code Online (Sandbox Code Playgroud)