我试图用几张图片展示最简单的小部件, 每次我试图显示应用程序崩溃,我得到空字符串引用
body = %q(
Hello <%= Name %>,
This is a test. hello test
some more stuff here
and here.
<%= Name %>
)
parsed_body = body.gsub(/\A<%= Name %>\Z/, "Some person")
puts parsed_body
我在小部件代码中切换了所有的tostrings和字符串实现,但它仍然没有帮助。
这是我的 MainClockWidget:
parsed_body
}
MainClockWidgetConfigureActivity:
Attempt to invoke interface method 'java.lang.String java.lang.CharSequence.toString()' on a null object reference
at java.lang.String.contains(String.java:2078)
at com.sec.location.nsflp2.a.a.c.b()
at com.sec.location.nsflp2.a.a.c.onForegroundActivitiesChanged()
at android.app.IProcessObserver$Stub.onTransact(IProcessObserver.java:55)
at android.os.Binder.execTransact(Binder.java:573)
和我的小部件xml
public class MainClockWidget extends AppWidgetProvider {
static void updateAppWidget(Context context, AppWidgetManager appWidgetManager,
int appWidgetId) {
CharSequence widgetText = MainClockWidgetConfigureActivity.loadTitlePref(context, appWidgetId);
// Construct the RemoteViews object
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.main_clock_widget);
views.setTextViewText(R.id.appwidget_text, "hellow");
// Instruct the widget manager to update the widget
appWidgetManager.updateAppWidget(appWidgetId, views);
}
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
// There may be multiple widgets active, so update all of them
for (int appWidgetId : appWidgetIds) {
updateAppWidget(context, appWidgetManager, appWidgetId);
}
}
@Override
public void onDeleted(Context context, int[] appWidgetIds) {
// When the user deletes the widget, delete the preference associated with it.
for (int appWidgetId : appWidgetIds) {
MainClockWidgetConfigureActivity.deleteTitlePref(context, appWidgetId);
}
}
@Override
public void onEnabled(Context context) {
// Enter relevant functionality for when the first widget is created
}
@Override
public void onDisabled(Context context) {
// Enter relevant functionality for when the last widget is disabled
}
可能是什么问题?
答案 0 :(得分:1)
从一些奇怪的原因修复它,这只是图像太大时的错误。 <调整图像大小>解决了问题