Android Wear的消息侦听器 [英] Android Wear Message Listener

查看:338
本文介绍了Android Wear的消息侦听器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一些帮助,我有Android Wear有消息API工作,但我坚持送一些命令,这是我的听众。

I need some help I have Android Wear with message api working but I'm stuck sending some commands this is my listener.

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.hardware.Camera;
import android.widget.ImageButton;
import android.widget.Toast;

import com.google.android.gms.wearable.MessageEvent;
import com.google.android.gms.wearable.WearableListenerService;
public class ListenerServiceFromWear extends WearableListenerService {
    private static final String HELLO_WORLD_WEAR_PATH = "/hello-world-wear" ;
    public void onMessageReceived(MessageEvent messageEvent) {
        if (messageEvent.getPath().equals(HELLO_WORLD_WEAR_PATH)) {
            // Toast.makeText(getApplicationContext(),
            //        "Button is clicked", Toast.LENGTH_LONG).show() ;
            Intent startIntent = new Intent(this, MainActivity.class) ;
            // startIntent.putExtra("name",0);
            startIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) ;
            startActivity(startIntent) ;

        }
        else {
            // android.os.Process.killProcess(android.os.Process.myPid());
        }
    }
}

我想打电话给我的code我的手机的方法,我可以初始化手机类,但在那之后我不能把更多的方法,如:上|关闭。如何调用在MainActivity类的方法?

I want to call the methods of my phone on my code I can initialize the phone class but after that I can't call more methods like : on | off. How do I call methods of the MainActivity class?

我也试过查杀过程,但磨损设备必须关闭并重新打开后作出回应。

I also tried killing the process but the Wear device must close and reopen to respond after that.

推荐答案

就以这个样子;)迄今发现的磨损情况最好的事情

Take a look on this ;) best thing ever found for Wear

https://github.com/Mariuxtheone/Teleport

这篇关于Android Wear的消息侦听器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆