0

I have question for using intent from host app to smart extension. I have Class ActivityReceiver inside hostapp

    package com.PrinterStatus.AppLab;

    import java.util.ArrayList;

    import android.app.Activity;
    import android.content.Context;
    import android.content.Intent;
    import android.os.Bundle;
    import android.view.LayoutInflater;
    import android.view.View;
    import com.sonyericsson.extras.liveware.extension.controlsample.*;

    public class ActivityToSmartWatch extends Activity {

    private Activity activity;
    private ArrayList<String[]> data;
    private static LayoutInflater inflater = null;
    public String[] inkLevels = new String[5];
    public final String EXTRA_MESSAGE = "com.PrinterStatus.AppLab.MESSAGE";
    View message;
    String [][] storePrintIMC= new String [4][4];
    public static final String ARRAYS_COUNT = "com.PrinterStatus.AppLab.ARRAYS_COUNT";
    public static final String ARRAY_INDEX = "com.PrinterStatus.AppLab.ARRAY_INDEX"; 



    public ActivityToSmartWatch(Activity a, ArrayList<String[]> inkLevels) {
        activity = a;
        data = inkLevels;
        inflater = (LayoutInflater) activity
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }

    public void sendMessage(View view) 
    {
        Bundle bundle = new Bundle();
        final String data[][] = storePrintIMC; 
        int count = data.length; 
        bundle.putInt(ARRAYS_COUNT, count); 
        for (int i = 0; i < count; i++)
        { 
            bundle.putStringArray(ARRAY_INDEX + i, data[i]); 
        } 
         Intent intent = new Intent(this, ActivityReceiver.class); 
         intent.putExtras(bundle);
         startActivity(intent);
    }

    public int getCount() {
        return data.size();
    }

    public Object getItem(int position) {
        return position;
    }

    public long getItemId(int position) {
        return position;
    }


    public String[] getPrintIMC (int position)
    {

        System.arraycopy(data.get(position), 0, inkLevels, 0, data.get(position).length);


        data.get(position);
        //sendMessage(message);
        if (position == 0 )
        {

            storePrintIMC[0][0]=inkLevels[0];
            storePrintIMC[0][1]=inkLevels[1];
            storePrintIMC[0][2]=inkLevels[2];
            storePrintIMC[0][3]=inkLevels[3];
        }
        if (position == 1 )
        {
            storePrintIMC[1][0]=inkLevels[0];
            storePrintIMC[1][1]=inkLevels[1];
            storePrintIMC[1][2]=inkLevels[2]; 
            storePrintIMC[1][3]=inkLevels[3];
        }
        if (position == 2 )
        {
            storePrintIMC[2][0]=inkLevels[0];
            storePrintIMC[2][1]=inkLevels[1];
            storePrintIMC[2][2]=inkLevels[2]; 
            storePrintIMC[2][3]=inkLevels[3];
        }
        if (position == 3 )
        {   
            storePrintIMC[3][0]=inkLevels[0];
            storePrintIMC[3][1]=inkLevels[1];
            storePrintIMC[3][2]=inkLevels[2]; 
            storePrintIMC[3][3]=inkLevels[3];
            //sendMessage(message);
        }

        return inkLevels;       
    }

    }

I want to send inkLevels to my smartextension(different package) so I using intent inside sendMessage method. And inside the smartextension, I have class activity receiver.

    package com.sonyericsson.extras.liveware.extension.controlsample;

import java.util.ArrayList;

import android.app.Activity;
import android.os.Bundle;


 public class ActivityReceiver extends Activity {

   public ArrayList<String[]> arrays ;
   public String[]color = new String [4];
   public  String[][] inkLev ;

    protected void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);
     Bundle bundle = getIntent().getExtras();

      if (bundle != null) 
      {

          int count = bundle.getInt("com.PrinterStatus.AppLab.ARRAYS_COUNT", 0);
          ArrayList<String[]> arrays = new ArrayList<String[]>(count);
          for (int i = 0; i < count; i++)
          {

              arrays.add(bundle.getStringArray("com.PrinterStatus.AppLab.ARRAY_INDEX" + i));
              String[][] inkLev = arrays.toArray(new String[][]{});
          }
      }

      }
    public String[] getInkLevel()
    {
        color[0]= inkLev[0][2];
        color[1]= inkLev[1][2];
        color[2]= inkLev[2][2];
        color[3]= inkLev[3][2];

        return color;

    }

  } 

I want to use variable color to show the value in interface which I will put in another class. But I still have problems with the way of coding.Why it still can't find the class?Did I forgot something?

09-10 09:12:08.750: E/dalvikvm(10340): Could not find class 'com.sonyericsson.extras.liveware.extension.controlsample.ActivityReceiver', referenced from method com.PrinterStatus.AppLab.ActivityToSmartWatch.sendMessage
09-10 09:12:08.750: W/dalvikvm(10340): VFY: unable to resolve const-class 670 (Lcom/sonyericsson/extras/liveware/extension/controlsample/ActivityReceiver;) in Lcom/PrinterStatus/AppLab/ActivityToSmartWatch;
Carlos
  • 59
  • 1
  • 6

3 Answers3

0

make sure that you have added ActivityReceiver in AndroidManifest.xml

Digit
  • 1,929
  • 1
  • 14
  • 17
  • I have already declare like this:. Is it correct? – Carlos Sep 10 '13 at 07:35
  • can you please visit http://stackoverflow.com/questions/11450421/how-to-add-activity-in-manifest-file and http://stackoverflow.com/questions/7511216/android-how-to-finish-an-activity-from-other-activity – Digit Sep 10 '13 at 07:57
0

This is happens when external libraries are not attached properly

VFY: unable to resolve const-class 670 (Lcom/sonyericsson

Check one thing have you checked all dependencies in "order and export"

enter image description here

Biraj Zalavadia
  • 28,348
  • 10
  • 61
  • 77
0

Did you add the right libraries:

Add SmartExtensionAPI and SmartExtension Utils as Libraries into your project

Check this answer out: Smartwatch Application Deployment

Community
  • 1
  • 1
Anup
  • 497
  • 3
  • 11