Back to project page ScoponeDaPolso.
The source code is released under:
GNU General Public License
If you think the Android project ScoponeDaPolso listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package org.gdg.bari.scopone.services; /*from w w w .j a va 2 s.co m*/ import android.content.Intent; import android.widget.Toast; import com.google.android.gms.wearable.DataMap; import com.mariux.teleport.lib.TeleportService; import org.gdg.bari.scopone.activity.WearMainActivity; /** * Created by tiziano on 16/11/14. */ public class WearTeleportService extends TeleportService { private static final String TAG = WearTeleportService.class.getSimpleName(); private static final String STARTACTIVITY_WEAR = "startActivityOnWear"; @Override public void onCreate() { super.onCreate(); setOnGetMessageTask(new StartActivityTask()); setOnSyncDataItemTask(new DataSyncTask()); } //Task that shows the path of a received message public class StartActivityTask extends TeleportService.OnGetMessageTask { @Override protected void onPostExecute(String path) { if (path.equals(STARTACTIVITY_WEAR)){ Intent startIntent = new Intent(getBaseContext(), WearMainActivity.class); startIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(startIntent); } //let`s reset the task (otherwise it will be executed only once) setOnGetMessageTask(new StartActivityTask()); } } public class DataSyncTask extends OnSyncDataItemTask { @Override protected void onPostExecute(DataMap result) { String jsonHand = result.getString("jsonHand"); Toast.makeText(getApplicationContext(), jsonHand, Toast.LENGTH_LONG).show(); //Log.d(TAG, jsonHand); Intent handIntent = new Intent(); handIntent.setAction(WearMainActivity.HAND_ACTION); handIntent.putExtra("jsonHand", jsonHand); sendBroadcast(handIntent); //setOnSyncDataItemTask(new DataSyncTask()); } } }