Android Wear Message Listener

霸气de小男生 提交于 2019-12-25 03:14:08

问题


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());
        }
    }
}

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.


回答1:


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

https://github.com/Mariuxtheone/Teleport



来源:https://stackoverflow.com/questions/28778481/android-wear-message-listener

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!