0

我对使用从主机应用程序到智能扩展的意图有疑问。我在 hostapp 中有 Class ActivityReceiver

    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;

    }

  } 

我想使用可变颜色来显示我将放在另一个类中的接口中的值。但是我的编码方式仍然有问题。为什么它仍然找不到类?我忘记了什么吗?

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;
4

3 回答 3

0

您是否添加了正确的库:

将 SmartExtensionAPI 和 SmartExtension Utils 作为库添加到您的项目中

检查这个答案:智能手表应用程序部署

于 2013-09-10T22:06:51.807 回答
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

于 2013-09-10T09:01:28.910 回答
0

确保您在 AndroidManifest.xml 中添加了 ActivityReceiver

于 2013-09-10T07:32:01.063 回答