пожалуйста, я в той же ситуации, пожалуйста, какие пользовательские действия вы использовали ???
я есть странный здесь ... У меня есть Motorola i1 с Nextel под управлением Android 1.5
У меня есть виджет Android. Когда я запускаю службу, которая обновляет этот виджет, я вижу изображение из другого виджета (Launch DC Contact)
Оно показывает это изображение в расположении моего виджета, но когда «обновление» моего виджета завершено, оно заменяется макетом, который у меня есть для моего виджета.
Это как если бы был кеш изображений виджетов, и он показывает вещи оттуда, пока не будет выполнено обновление моего виджета.
Если мое обновление занимает много времени, пользователь может увидеть это странное изображение в течение 2-3 секунд.
public void onUpdate(Context context, AppWidgetManager appWidgetManager,
int[] appWidgetIds) {
Log.d(TAG, "Enter onUpdate");
final int N = appWidgetIds.length;
for (int i = 0; i < N; i++) {
int widgetId = appWidgetIds[i];
RemoteViews views = new RemoteViews(context.getPackageName(),
R.layout.widget_initial_layout);
Intent intent = new Intent(context, MainActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0,
intent, 0);
views.setOnClickPendingIntent(R.id.WidgetLayout, pendingIntent);
views.setTextViewText(R.id.NEWCountTextView, Integer.toString(NEWC));
views.setTextViewText(R.id.ACKCountTextView, Integer.toString(ACKC));
views.setTextViewText(R.id.PKUCountTextView, Integer.toString(PKUC));
views.setTextViewText(R.id.PODCountTextView, Integer.toString(PODC));
if (errorMessage.contentEquals("")) {
errorMessage = (new Date()).toString();
views.setTextColor(R.id.LastUpdatedTextView, Color.BLACK);
} else {
views.setTextColor(R.id.LastUpdatedTextView, Color.RED);
}
views.setTextViewText(R.id.LastUpdatedTextView, errorMessage);
appWidgetManager.updateAppWidget(widgetId, views);
}
Log.d(TAG, "Exit onUpdate");
}
public void onReceive(Context context, Intent intent) {
Log.d(TAG, "Enter onReceive");
String action = intent.getAction();
if (action.contentEquals("android.appwidget.action.APPWIDGET_UPDATE")) {
Bundle extras = intent.getExtras();
if (extras != null) {
NEWC = extras.getInt("NEWCOUNT");
ACKC = extras.getInt("ACKCOUNT");
PKUC = extras.getInt("PKUCOUNT");
PODC = extras.getInt("PODCOUNT");
errorMessage = extras.getString("ERRORMESSAGE");
}
}
super.onReceive (контекст, намерение); Log.d (TAG, «Выход при получении»); } здесь макет
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/WidgetLayout"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:gravity="top"
android:orientation="vertical"
android:background="@drawable/bg"
>
<TextView
android:text="ORDERS"
android:id="@+id/TextView01"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="25dip"
android:gravity="top|center"
android:textColor="#ffff00"
android:textStyle="bold"
/>
<TextView
android:text=""
android:id="@+id/TextView01"
android:layout_width="fill_parent"
android:layout_height="6dip"
android:gravity="top|center"
android:background="#0000ff"
/>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearLayout02"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:gravity="top|center"
android:orientation="horizontal"
>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/CountsLinearLayout"
android:layout_height="fill_parent"
android:layout_width="wrap_content"
android:gravity="top"
android:orientation="vertical"
>
<TextView
android:text="NEW"
android:id="@+id/TextView11"
android:layout_width="75dip"
android:layout_height="wrap_content"
android:textSize="25dip"
android:gravity="center"
android:textColor="#000000"
android:textStyle="bold"
/>
<TextView
android:text=""
android:id="@+id/NEWCountTextView"
android:layout_width="75dip"
android:layout_height="wrap_content"
android:textSize="25dip"
android:gravity="center"
android:textColor="#000000"
android:textStyle="bold"
/>
</LinearLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearLayout04"
android:layout_height="fill_parent"
android:layout_width="wrap_content"
android:gravity="top"
android:orientation="vertical"
>
<TextView
android:text="ACK"
android:id="@+id/TextView21"
android:layout_width="75dip"
android:layout_height="wrap_content"
android:textSize="25dip"
android:gravity="center"
android:textColor="#000000"
android:textStyle="bold"
/>
<TextView
android:text=""
android:id="@+id/ACKCountTextView"
android:layout_width="75dip"
android:layout_height="wrap_content"
android:textSize="25dip"
android:gravity="center"
android:textColor="#000000"
android:textStyle="bold"
/>
</LinearLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearLayout05"
android:layout_height="fill_parent"
android:layout_width="wrap_content"
android:gravity="top"
android:orientation="vertical"
>
<TextView
android:text="PKU"
android:id="@+id/TextView31"
android:layout_width="75dip"
android:layout_height="wrap_content"
android:textSize="25dip"
android:gravity="center"
android:textColor="#000000"
android:textStyle="bold"
/>
<TextView
android:text=""
android:id="@+id/PKUCountTextView"
android:layout_width="75dip"
android:layout_height="wrap_content"
android:textSize="25dip"
android:gravity="center"
android:textColor="#000000"
android:textStyle="bold"
/>
</LinearLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearLayout06"
android:layout_height="fill_parent"
android:layout_width="wrap_content"
android:gravity="top"
android:orientation="vertical"
>
<TextView
android:text="POD"
android:id="@+id/TextView41"
android:layout_width="75dip"
android:layout_height="wrap_content"
android:textSize="25dip"
android:gravity="center"
android:textColor="#000000"
android:textStyle="bold"
/>
<TextView
android:text=""
android:id="@+id/PODCountTextView"
android:layout_width="75dip"
android:layout_height="wrap_content"
android:textSize="25dip"
android:gravity="center"
android:textColor="#000000"
android:textStyle="bold"
/>
</LinearLayout>
</LinearLayout>
<TextView
android:text=""
android:id="@+id/TextView01"
android:layout_width="fill_parent"
android:layout_height="6dip"
android:gravity="bottom|center"
android:background="#0000ff"
/>
<TextView
android:text=""
android:id="@+id/LastUpdatedTextView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="15dip"
android:gravity="center"
android:textColor="#000000"
android:textStyle="bold"
/>
</LinearLayout>
Вы видели что-нибудь подобное?
Спасибо