簡體   English   中英

Android Wear消息監聽器

[英]Android Wear Message Listener

我需要一些幫助,讓Android Wear可以運行消息api,但是我一直在發送一些命令,這是我的偵聽器。

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

我想在代碼上調用手機的方法,我可以初始化手機類,但是之后,我不能調用更多的方法,例如:on | 關。 如何調用MainActivity類的方法?

我也嘗試終止該過程,但是Wear設備必須關閉然后重新打開才能做出響應。

看看這個;)有史以來為Wear找到的最好的東西

https://github.com/Mariuxtheone/Teleport

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM