无法使用com.tns来查找类

问题描述 投票:0回答:1

我正在尝试使用Nativescript和Angular创建一个小部件。

我使用this示例来帮助我进一步,但现在我被困在这个代码上。

我在互联网上找不到任何帮助,也无法自己解决。

这是我的组件很多类似于我使用的例子,因为我是Nativescript的新手。

@JavaProxy("a.b.MyWidget")
export class WidgetComponent extends android.appwidget.AppWidgetProvider {

    onUpdate(context, appWidgetManager, appWidgetIds): void {
      var appWidgetsLen = appWidgetIds.length

      for (let i = 0; i < appWidgetsLen; i++) {
        this.updateWidget(context, appWidgetManager, appWidgetIds, appWidgetIds[i]);
      }
    }

    updateWidget(ontext, appWidgetManager, appWidgetIds, widgetId){
      const context = app.android.context;

      let views:any = context.getResources().getIdentifier("appwidget", "layout", context.getPackageName());
      let resourceId:any = context.getResources().getIdentifier("appwidget", "id", context.getPackageName())

      var textView = new android.widget.RemoteViews(context.getPackageName(), views);
      textView.setTextViewText(resourceId.taps_text, "Just for testing");

      var intent: android.content.Intent = new android.content.Intent(context, com.tns.MyWidget);

      intent.setAction(android.appwidget.AppWidgetManager.ACTION_APPWIDGET_UPDATE);
      intent.putExtra(android.appwidget.AppWidgetManager.EXTRA_APPWIDGET_IDS, appWidgetIds);

      var startAppIntent = new android.content.Intent(context, com.tns.NativeScriptActivity.class); // the activity defined in AndroidManifest
      startAppIntent.putExtra(android.appwidget.AppWidgetManager.EXTRA_APPWIDGET_ID, widgetId);


      appWidgetManager.updateAppWidget(widgetId, textView);
    }
}

在布局文件中没有文本属性,我想从组件中设置它。

当我调用意图时,它会卡在com.tns.MyWidget的部分上。

android angular typescript android-widget nativescript
1个回答
0
投票

您已将JavaProxy声明为a.b.MyWidget,因此您必须在示例中访问相同而不是com.tns.MyWidget

© www.soinside.com 2019 - 2024. All rights reserved.