Android Open Source - ScoponeDaPolso Wear Teleport Service






From Project

Back to project page ScoponeDaPolso.

License

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.

Java Source Code

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




Java Source Code List

com.google.example.games.basegameutils.BaseGameActivity.java
com.google.example.games.basegameutils.BaseGameUtils.java
com.google.example.games.basegameutils.GameHelperUtils.java
com.google.example.games.basegameutils.GameHelper.java
com.mariux.teleport.lib.ApplicationTest.java
com.mariux.teleport.lib.TeleportClient.java
com.mariux.teleport.lib.TeleportService.java
org.gdg.bari.entities.ApplicationTest.java
org.gdg.bari.entities.Card.java
org.gdg.bari.entities.Constants.java
org.gdg.bari.entities.Deck.java
org.gdg.bari.entities.Score.java
org.gdg.bari.entities.TableTurn.java
org.gdg.bari.entities.Table.java
org.gdg.bari.entities.TeleportClientManager.java
org.gdg.bari.scopone.ApplicationTest.java
org.gdg.bari.scopone.activity.MobileGameActivity.java
org.gdg.bari.scopone.activity.MobileMainActivity.java
org.gdg.bari.scopone.activity.WearConfirmationActivity.java
org.gdg.bari.scopone.activity.WearMainActivity.java
org.gdg.bari.scopone.fragment.CardListFragment.java
org.gdg.bari.scopone.fragment.GameFragment.java
org.gdg.bari.scopone.fragment.LoginFragment.java
org.gdg.bari.scopone.fragment.MenuFragment.java
org.gdg.bari.scopone.service.MobileTeleportService.java
org.gdg.bari.scopone.services.WearTeleportService.java
org.gdg.bari.scopone.util.GoogleApiClientManager.java
org.gdg.bari.scopone.util.LogUtil.java