title: android wear message api start activity and methods
body: <p>I have a problem with the android wear device I can turn on the camera with the message api by loading turnOn() onCreate on mobile device.</p>
  
  <p>Problem One: I can't open an activity if the phone is locked.
  Problem Two: I can start only one activity if the phone is unlocked but can't call methods of the phone. The only way I started the camera was starting the MainActivity on the Oncreate() method using the wearListener service.</p>
  
  <p>I want something like this app: <a href="https://play.google.com/store/apps/details?id=com.jumpbyte.flashlight" rel="nofollow">https://play.google.com/store/apps/details?id=com.jumpbyte.flashlight</a></p>
  
  <p>Here is my code:
  Oncreate method phone</p>
  
  <pre><code>protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          Intent intent = getIntent() ;
          int valor = intent.getIntExtra("parameter",0);
          String value = "key" ;
          if (valor == 0){
              boolean isCameraFlash = getApplicationContext().getPackageManager()
                      .hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH);
              if(!isCameraFlash) {
                  showCameraAlert();
              } else {
                  camera = Camera.open();
                  params = camera.getParameters();
              }
              if(isFlashlightOn) {
                  setFlashlightOff();
              } else {
                  setFlashlightOn();
              }
          }
          else{
              finish();
          }
          /* boolean isCameraFlash = getApplicationContext().getPackageManager()
                  .hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH);
          if(!isCameraFlash) {
              showCameraAlert();
          } else {
              camera = Camera.open();
              params = camera.getParameters();
          }
  
          if(isFlashlightOn) {
              setFlashlightOff();
          } else {
              setFlashlightOn();
          }
  
  */
      }
  </code></pre>
  
  <p>Listener phone:</p>
  
  <pre><code>private static final String HELLO_WORLD_WEAR_PATH = "/hello-world-wear" ;
      public void onMessageReceived(MessageEvent messageEvent) {
          if (messageEvent.getPath().equals(HELLO_WORLD_WEAR_PATH)) {
              // AudioManager audiomanager ;
              // audiomanager = (AudioManager)getSystemService(Context.AUDIO_SERVICE) ;
              // audiomanager = (AudioManager)getSystemService(Context.AUDIO_SERVICE) ;
              // audiomanager.adjustVolume(AudioManager.ADJUST_RAISE, AudioManager.FLAG_SHOW_UI) ;
              // Toast.makeText(getApplicationContext(), "Volume Up | Vibration Time Increased", Toast.LENGTH_SHORT).show() ;
              //light lightOne = new light();
              // MainActivity one = new MainActivity() ;
              // one.messageone();
              // lightOne.on();
              // Toast.makeText(getApplicationContext(),
              //        "Button is clicked", Toast.LENGTH_LONG).show() ;
              Intent startIntent = new Intent(this, MainActivity.class) ;
              startIntent.putExtra("parameter", 0); //Optional parameters
              startIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) ;
              startActivity(startIntent) ;
              /* if(isFlashlightOn) {
                  setFlashlightOff();
              } else {
                  setFlashlightOn();
              }
              */
          } else {
  
          } } }
  </code></pre>
  
  <p>Wear main class:</p>
  
  <pre><code>private void sendMessage() {
          if (mNode != null &amp;&amp; mGoogleApiClient!=null &amp;&amp; mGoogleApiClient.isConnected()) {
              Wearable.MessageApi.sendMessage(
                      mGoogleApiClient, mNode.getId(), HELLO_WORLD_WEAR_PATH, null).setResultCallback(
  
                      new ResultCallback&lt;MessageApi.SendMessageResult&gt;() {
                          @Override
                          public void onResult(MessageApi.SendMessageResult sendMessageResult) {
  
                              if (!sendMessageResult.getStatus().isSuccess()) {
                                  Log.e("TAG", "Failed to send message with status code: "
                                          + sendMessageResult.getStatus().getStatusCode());
                              }
                          }
                      }
              );
          }else{        } }
      protected void onStart() {
          super.onStart() ;
          if (!mResolvingError) {
              mGoogleApiClient.connect() ;
          } }
      private void resolveNode() {
          Wearable.NodeApi.getConnectedNodes(mGoogleApiClient).setResultCallback(new ResultCallback&lt;NodeApi.GetConnectedNodesResult&gt;() {
              @Override
              public void onResult(NodeApi.GetConnectedNodesResult nodes) {
                  for (Node node : nodes.getNodes()) {
                      mNode = node ; }     }
          }) ; }
      public void onConnected(Bundle bundle) {
          resolveNode();
      }
      public void onConnectionSuspended(int i) {
          //Improve your code
      }
      public void onConnectionFailed(ConnectionResult connectionResult) {
          //Improve your code
      }
  </code></pre>
  
  <p>Can someone help me out with this to problems please I can't find any way to pass those two problems. I want something like this app: <a href="https://play.google.com/store/apps/details?id=com.jumpbyte.flashlight" rel="nofollow">https://play.google.com/store/apps/details?id=com.jumpbyte.flashlight</a></p>