问题
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