我的代码如下:错误出现在try里面的mAppWidgetManager.bindAppWidgetId(appWidgetId, xmicIntent.getComponent()); 错误为: ERROR/AndroidRuntime(335): Caused by: java.lang.reflect.InvocationTargetException
请教各位高人,错的原因是什么呢?要如何改呢
Intent xmicIntent = new Intent(Intent.ACTION_MAIN, null);
xmicIntent.addCategory(Intent.CATEGORY_DEFAULT);
mAppWidgetManager = AppWidgetManager.getInstance(this);
List installed = mAppWidgetManager.getInstalledProviders();
String packageName = installed.get(0).provider.getPackageName();
String className = installed.get(0).provider.getClassName();
intent.setClassName(packageName, className);
try {
mAppWidgetManager.bindAppWidgetId(appWidgetId, xmicIntent.getComponent());
} catch (IllegalArgumentException e) {
Log.v("TEST", "hello-----------------------------------------------------");
}
addAppWidget(xmicIntent);