I have a simple application and I want a homescreen widget (an Image) that runs the app from one of the activities, not exactly the Main Activity. I have no errors in the compilation, running the app or installing it, but the widget isn't installed neither in a tablet or a phone I am using for testing. So... this is what I am doing.
widget_info.xml
<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider
xmlns:android="http://schemas.android.com/apk/res/android"
android:initialLayout="@layout/widget_layout"
android:minHeight="146dp"
android:minWidth="146dp"
android:configure=".MyWidgetProvider"
android:widgetCategory="home_screen|keyguard"
android:previewImage="@drawable/ic_launcher"
android:updatePeriodMillis="3000" >
</appwidget-provider>
widget_layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout"
android:orientation="horizontal"
android:layout_width="146dp"
android:layout_height="146dp"
android:layout_margin="8dip"
android:background="@drawable/ic_launcher" >
</LinearLayout>
MyWidgetProvider.java
package com.project;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.ComponentName;
import android.content.Context;
import android.widget.RemoteViews;
public class MyWidgetProvider extends AppWidgetProvider {
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager,
int[] appWidgetIds) {
RemoteViews remoteViews = new RemoteViews(context.getPackageName(),R.layout.widget_layout);
ComponentName myWidget = new ComponentName(context,MyWidgetProvider.class);
AppWidgetManager manager = AppWidgetManager.getInstance(context);
manager.updateAppWidget(myWidget, remoteViews);
}
}
And this is the receiver inside Application in the AndroidManifest.xml
<receiver android:name="Detente" >
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
<action android:name="android.appwidget.action.ACTION_WIDGET_RECEIVER"/>
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="@xml/widget_info" />
</receiver>
Do I need to add any permission or something like that or maybe this "android:installLocation="preferExternal"" is causing conflict?
(I'm running the tests on a Lenovo Tab whit ICS and a LG 3D-Max with GB )
I need this for tomorrow, please help. :D