private void handleLaunchMessageEvent(MessageEvent messageEvent){
  DataMap dataMap=DataMap.fromByteArray(messageEvent.getData());
  boolean relaunchIfRunning=dataMap.getBoolean(KEY_START_ACTIVITY_RELAUNCH,false);
  DataMap bundleData=dataMap.getDataMap(KEY_START_ACTIVITY_BUNDLE);
  String activityName=dataMap.getString(KEY_START_ACTIVITY_NAME);
  Bundle bundle=null;
  if (bundleData != null) {
    bundle=bundleData.toBundle();
  }
  if (activityName == null) {
    for (    WearConsumer consumer : mWearConsumers) {
      consumer.onWearableApplicationLaunchRequestReceived(bundle,relaunchIfRunning);
    }
  }
 else {
    try {
      if (!TextUtils.isEmpty(activityName)) {
        Class<?> targetActivity=Class.forName(activityName);
        Intent intent=new Intent(mContext,targetActivity);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        if (bundle != null) {
          intent.putExtras(bundle);
        }
        if (!mAppForeground || relaunchIfRunning) {
          mContext.startActivity(intent);
        }
      }
 else {
        Log.e(TAG,"Activity Name cannot be empty");
      }
    }
 catch (    ClassNotFoundException e) {
      Log.e(TAG,"Failed to find the activity class to launch",e);
    }
  }
}

private void handleLaunchMessageEvent ( MessageEvent messageEvent ) { DataMap dataMap = DataMap . fromByteArray ( messageEvent . getData ( ) ) ; boolean relaunchIfRunning = dataMap . getBoolean ( KEY_START_ACTIVITY_RELAUNCH , false ) ; DataMap bundleData = dataMap . getDataMap ( KEY_START_ACTIVITY_BUNDLE ) ; String activityName = dataMap . getString ( KEY_START_ACTIVITY_NAME ) ; Bundle bundle = null ; if ( bundleData != null ) { bundle = bundleData . toBundle ( ) ; } if ( activityName == null ) { for ( WearConsumer consumer : mWearConsumers ) { consumer . onWearableApplicationLaunchRequestReceived ( bundle , relaunchIfRunning ) ; } } else { try { if ( ! TextUtils . isEmpty ( activityName ) ) { Class < ? > targetActivity = Class . forName ( activityName ) ; Intent intent = new Intent ( mContext , targetActivity ) ; intent . setFlags ( Intent . FLAG_ACTIVITY_NEW_TASK ) ; if ( bundle != null ) { intent . putExtras ( bundle ) ; } if ( ! mAppForeground || relaunchIfRunning ) { mContext . startActivity ( intent ) ; } } else { Log . e ( TAG , "Activity Name cannot be empty" ) ; } } catch ( ClassNotFoundException e ) { Log . e ( TAG , "Failed to find the activity class to launch" , e ) ; } } }
handles the special message to launch an activity .
