I have an application and I have also created an app widget for it. The app widget is just a shortcut to launch application.
My manifestfile:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.hansem.handbookmanual"
android:installLocation="internalOnly"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:exported="true"
android:theme="#style/AppTheme" >
<receiver android:name="com.example.HandbookAppWidgetProvider" android:label="abc">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data android:name="android.appwidget.provider" android:resource="#xml/widget1_info" />
</receiver>
<activity
android:name="com.example.BrowserLauncherActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Widget1_info.xml
<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:minWidth="72dp"
android:minHeight="72dp"
android:minResizeHeight="72dp"
android:resizeMode="vertical"
android:updatePeriodMillis="0"
android:initialLayout="#layout/widget1">
</appwidget-provider>
Widget1.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/button_applaunch"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="4dp"
android:background="#drawable/ic_launcher"
android:gravity="center"
android:orientation="vertical" >
</LinearLayout>
I have tried all the solution mentioned on Stackflow but noting helped. On restarting the device, the widget gets added, but normally by just installing the app on phone and launching it, the widget is not added.
AppWidgetProviderCode:
public class HandbookAppWidgetProvider extends AppWidgetProvider {
DateFormat df = new SimpleDateFormat("hh:mm:ss");
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
final int N = appWidgetIds.length;
Log.i("ExampleWidget", "Updating widgets " + Arrays.asList(appWidgetIds));
// Perform this loop procedure for each App Widget that belongs to this
// provider
for (int i = 0; i < N; i++) {
int appWidgetId = appWidgetIds[i];
// Create an Intent to launch ExampleActivity
Intent intent = new Intent(context, BrowserLauncherActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
// Get the layout for the App Widget and attach an on-click listener
// to the button
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget1);
views.setOnClickPendingIntent(R.id.button_applaunch, pendingIntent);
// To update a label
//views.setTextViewText(R.id.widget1label, df.format(new Date()));
// Tell the AppWidgetManager to perform an update on the current app
// widget
appWidgetManager.updateAppWidget(appWidgetId, views);
}
}
}
Please help
Related
I'm learning the ropes with Android development, so forgive me, and I'm struggling to do something pretty fundamental.
I'm trying to fetch an image from a remote URL and put it into an ImageView. The ImageView itself is within an app widget.
But the image never loads, and a ton of errors are returned.
I created the app widget code using Android Studio's context menu, so the building blocks are, I think, sound. I created an ImageView in the app widget's layout in place of the TextView that was there by default.
Here is all the relevant code:
layout/new_app_widget.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="#dimen/widget_margin" >
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/imageView"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:contentDescription="#string/content" />
</RelativeLayout>
relevant bit from NewAppWidget.java:
public class NewAppWidget extends AppWidgetProvider {
...
static void updateAppWidget(Context context, AppWidgetManager appWidgetManager,
int appWidgetId) {
// Construct the RemoteViews object
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.new_app_widget);
String strURL = "http://example.com/YqLOSfr4.png";
try{
URL urlURL = new URL(strURL);
HttpURLConnection con = (HttpURLConnection)urlURL.openConnection();
InputStream is = con.getInputStream();
Bitmap bmp = BitmapFactory.decodeStream(is);
views.setImageViewBitmap(R.id.imageView, bmp);
} catch(Exception e) {
e.printStackTrace();
}
// Instruct the widget manager to update the widget
appWidgetManager.updateAppWidget(appWidgetId, views);
}
}
AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mike.widgetapptest" >
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
android:debuggable="true"
<activity
android:name=".MyActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name=".NewAppWidget" >
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="#xml/new_app_widget_info" />
</receiver>
</application>
</manifest>
I'm new to android development. At the moment I'm trying to write an app widget. I've done a few widget tutorials and when I go to run them the app will run but the widget isn't showing up on the widget list to be used. Widgets that are not extensions of an app still will run as if they are an app and will not show up in the widgets list. This is happening with all the widgets iv tried to run. No errors are showing. Somebody please help its driving me mad. Thanks
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.somethinginspiring"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.somethinginspiring.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- declaring widget -->
<receiver android:name="AppWidgetProv"
android:label="#string/app_name"
android:icon="#drawable/ic_launcher">
<intent-filter >
<action
android:name="android.appwidget.action.APPWIGET_UPDATE"/>
</intent-filter>
<!-- declaring the widget_info -->
<meta-data
android:name="android.appwidget.provider"
android:resource="#xml/widget_info"/>
</receiver>
<!-- declaring broadcaster -->
<receiver
android:name="WidgetIntentReceiver"
android:label="WidgetBroadcastReceiver" >
<intent-filter>
<action android:name="android.appwidget.intent.action.CHANGE_PICTURE"/>
</intent-filter>
<!-- declaring meta-data -->
<meta-data
android:name="android.appwidget.provider"
android:resource="#xml/widget_info"/>
</receiver>
</application>
</manifest>
widget info xml file
<?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="72dp"
android:minWidth="300dp"
android:widgetCategory="home_screen"
android:minResizeHeight="72dp"
android:minResizeWidth="300dp"
android:updatePeriodMillis="2000000">
<!-- android:updatePerMillis="3000000" -->
</appwidget-provider>
widget layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ImageView
android:id="#+id/widget_image_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="#string/image_view_text"
android:clickable="true"
android:src="#drawable/j_1" >
</ImageView>
</LinearLayout>
app widget provider
import android.app.PendingIntent;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.widget.RemoteViews;
public class AppWidgetProv extends AppWidgetProvider {
#Override
public void onEnabled(Context context) {
// TODO Auto-generated method stub
super.onEnabled(context);
}
#Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager,
int[] appWidgetIds) {
RemoteViews remoteView = new RemoteViews(context.getPackageName(), R.layout.widget_layout);
remoteView.setOnClickPendingIntent(R.id.widget_image_view, buildButtonPendingIntent(context));
super.onUpdate(context, appWidgetManager, appWidgetIds);
}
public PendingIntent buildButtonPendingIntent(Context context) {
Intent changePicture = new Intent();
changePicture.setAction("android.widget.intent.action.CHANGE_PICTURE");
return PendingIntent.getBroadcast(context, 0, changePicture, PendingIntent.FLAG_UPDATE_CURRENT);
}
public static void pushWidgetUpdate(Context context, RemoteViews remoteView){
ComponentName widget = new ComponentName(context, AppWidgetProv.class);
AppWidgetManager manager = AppWidgetManager.getInstance(context);
manager.updateAppWidget(widget, remoteView);
}
}
widget intent broadcast receiver
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.widget.RemoteViews;
public class WidgetIntentReceiver extends BroadcastReceiver {
private static int currentImage = 0;
int[] images = {R.drawable.j_1};
#Override
public void onReceive(Context context, Intent intent) {
if(intent.getAction().equals("android.appwidget.intent.action.CHANGE_PICTURE"));
RemoteViews remote = new RemoteViews(context.getPackageName(),R.layout.widget_layout);
remote.setImageViewResource(R.id.widget_image_view, getImageToSet());
}
private int getImageToSet(){
currentImage++;
return currentImage = currentImage % images.length ;
}
}
There is a typo in your manifest. This:
<action android:name="android.appwidget.action.APPWIGET_UPDATE"/>
should be changed to this:
<action android:name="android.appwidget.action.APPWIDGET_UPDATE"/>
Notice the missing "D" in "APPWIGET_UPDATE" in the original.
I'm trying to launch my MainActivity from my AppWidget with pending intent but I can't figure out why it doesn't fire the intent. The widget has a ListView with up to 3 items, which is bind to a RemoteViewsService. I want to start my MainActivity when any of the rows is clicked. Can anyone tell me what I might done wrong?
I already checked some related posts like this Launching an activity from an AppWidget, and even tried to run the sample from here https://github.com/commonsguy/cw-advandroid/tree/master/AppWidget, and while the sample works, still can't tell what I did differently.
Here are some of my code that are relevant, please let me know if I should post more, and apologize in advance if my post doesn't look right as this is my first question:
Widget layout:
<?xml version="1.0" encoding="utf-8"?>
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/stocks"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
AppWidgetProvider class:
#Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
Log.d(LOGTAG, "onUpdate");
Log.d(LOGTAG, "appWidgetIds.length="+appWidgetIds.length);
for (int i = 0; i < appWidgetIds.length; ++i) {
Log.d(LOGTAG, "appWidgetIds[i]="+appWidgetIds[i]);
}
// update each of the app widgets with the remote adapter
for (int i = 0; i < appWidgetIds.length; ++i) {
updateWidget(context, appWidgetManager, appWidgetIds[i]);
}
super.onUpdate(context, appWidgetManager, appWidgetIds);
}
public void updateWidget(Context context, AppWidgetManager appWidgetManager, int appWidgetId) {
Log.d(LOGTAG, "updateWidget id="+appWidgetId);
// Sets up the intent that points to the StackViewService that will
// provide the views for this collection.
Intent intent = new Intent(context, StockAppWidgetService.class);
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
// When intents are compared, the extras are ignored, so we need to embed the extras
// into the data so that the extras will not be ignored.
intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
RemoteViews rv = new RemoteViews(context.getPackageName(), R.layout.stock_appwidget);
rv.setRemoteAdapter(R.id.stocks, intent);
Intent contentIntent = new Intent(context, MainActivity.class);
//contentIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent startAppPendingIntent =
PendingIntent.getActivity(context, 0, contentIntent, 0);
rv.setPendingIntentTemplate(R.id.stocks, startAppPendingIntent);
appWidgetManager.updateAppWidget(appWidgetId, rv);
}
manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="x40241.chris.yuan.a4.app"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="16" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#android:style/Theme.Holo.Light.DarkActionBar" >
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".SearchableActivity" >
<intent-filter>
<action android:name="x40241.chris.yuan.a4.app.SEARCH" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<service android:name=".StockServiceImpl" />
<service android:name=".StockAppWidgetService"
android:permission="android.permission.BIND_REMOTEVIEWS" />
<receiver android:name=".ServiceLauncher">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<receiver android:name=".StockAppWidgetProvider" >
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data android:name="android.appwidget.provider"
android:resource="#xml/stock_appwidget_info" />
</receiver>
</application>
</manifest>
I think I found the answer, or at least a workable solution in a related post:
AdapterViewFlipper in app widget: setPendingIntentTemplate() and setOnClickFillInIntent() not working
It turns out I wasn't setting the FillInIntent properly. I should call setOnClickFillInIntent on the top level view of the list item instead of the list itself. Here's the code change that made it work in RemoteViewsFactory:
public RemoteViews getViewAt(int position) {
if (DEBUG) Log.d(LOGTAG, "StockRemoteViewsFactory getViewAt position="+position);
RemoteViews rv = new RemoteViews(mContext.getPackageName(), R.layout.widget_item);
rv.setTextViewText(R.id.text_symbol, mStockItems.get(position).getSymbol());
rv.setTextViewText(R.id.text_price, String.format("$%.2f", mStockItems.get(position).getPrice()));
Intent fillInIntent = new Intent(Intent.ACTION_MAIN);
fillInIntent.putExtra(StockAppWidgetProvider.ITEM_NUM, position);
// set on the top level view of the list item, instead of the list view itself
//rv.setOnClickFillInIntent(R.id.stocks, fillInIntent);
rv.setOnClickFillInIntent(R.id.general_layout, fillInIntent);
return rv;
}
For me I have a button widget with a button that is just suppose to launch a helloworld activity when I click it. I've tried following many posts online including this one, and yet the problem still there. I press the button, nothing happens. I am working on version 2.3 of android. Can someone point out what I am doing wrong?
My widget:
public class IconWidgetProvider extends AppWidgetProvider {
#Override
public void onUpdate(final Context context, final AppWidgetManager appWidgetManager, final int[] appWidgetIds) {
final int N = appWidgetIds.length;
for (int i=0; i<N; i++) {
final Intent intent = new Intent(Intent.ACTION_MAIN, null);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
// first param is app package name, second is package.class of the main activity
final ComponentName cn = new ComponentName("com.followup","com.followup.FollowUpActivity");
intent.setComponent(cn);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
final PendingIntent myPI = PendingIntent.getActivity(context, 0, intent, 0);
final RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.icon_widget_layout);
views.setOnClickPendingIntent(R.id.image_in_widget, myPI);
final AppWidgetManager mgr = AppWidgetManager.getInstance(context); mgr.updateAppWidget(cn, views);
}
}
}
homescreeniconinfo.xml
<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:minWidth="146dip"
android:minHeight="72dip"
android:updatePeriodMillis="0"
android:initialLayout="#layout/icon_widget_layout" >
</appwidget-provider>
icon_widget_layout.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<Button android:name="#+id/image_in_widget"
android:contentDescription="#string/iconDescription"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight=".50"
android:clickable="true"
/>
</LinearLayout>
mainifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.followup"
android:versionCode="1"
android:versionName="1.0" >
.
.
.
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
.
.
.
<!-- Home icon widget -->
<receiver android:name="IconWidgetProvider"
android:label="#string/app_name"
android:icon="#drawable/ic_launcher">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="#xml/homescreeniconinfo" />
</receiver>
<activity
android:name=".FollowUpActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Have you tried adding the event handler to your button?
Perhaps I'm confused here as it's been a while since I actually did some intense android programming, but from what I understand, this is what I've done to call an intent from another one in the past...
<Button android:name="#+id/image_in_widget"
android:contentDescription="#string/iconDescription"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight=".50"
android:clickable="true"
android:onClick="onClickFunction"
/>
Paying extra attention to
android:onClick="onClickFunction"
Where "onClickFunction" would be a written method somewhere in your code that gets called when the button is clicked
public void onClickFunction(View view){
//stuff to do on click
}
EDIT
This is ripped straight from the HelloWorld android tutorial which I have compiled and successfully run on my 2.3 Android Phone in the past
this is the xml
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/button_send"
android:onClick="sendMessage" />
this is in the main .java file
/* called when the user clicks a button */
public void sendMessage(View view)
{
Intent intent = new Intent(this, DisplayMessageActivity.class);
EditText editText = (EditText)findViewById(R.id.edit_message);
String message = editText.getText().toString();
intent.putExtra(EXTRA_MESSAGE, message);
startActivity(intent);
}
DisplayMessageActivity.class is the class that is essentially a new application (from your case I believe you want it to be a Hello World app)
so you would make an XML for that called application and change/rewrite the DisplayMessageActivity class to do whatever "HelloWorld"-ey stuff you want...
I am doing a simple widget for the first time and it seems the tutorial I'm using has something missing because my LogCat states "Error inflating AppWidget" when selecting it from the pop up list of widgets.
According to the tutorial I did these.
Layout:
<TextView android:id="#+id/widget_textview" android:text="#string/widget_text"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:layout_gravity="center_horizontal|center"
android:layout_marginTop="5dip" android:padding="10dip"
android:textColor="#android:color/black" />
</LinearLayout>
Class:
package hello.widget;
import android.appwidget.AppWidgetProvider;
public class HelloWidget extends AppWidgetProvider {
}
Strings:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Hello Widget</string>
<string name="widget_text">Hello Widget!</string>
</resources>
Widget Provider:
<?xml version="1.0" encoding="utf-8"?>
appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android">
android:minWidth="146dip"
android:minHeight="72dip"
android:updatePeriodMillis="10000"
android:initialLayout="#layout/main"
</appwidget-provider>
Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="hello.widget" android:versionCode="1" android:versionName="1.0">
<uses-sdk android:minSdkVersion="3" />
<application android:icon="#drawable/icon" android:label="#string/app_name">
<!-- Broadcast Receiver that will process AppWidget updates -->
<receiver android:name="hello.widget.HelloWidget" android:label="#string/app_name">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data android:name="android.appwidget.provider"
android:resource="#xml/hello_widget_provider" />
</receiver>
</application>
</manifest>
You are missing the opening <LinearLayout> in your layout file. What you have here should not even compile.
You are also missing the entire implementation of your AppWidgetProvider. You need to implement onUpdate() to specify what the app widget should be displaying.
Also, your updatePeriodMillis is shorter than allowed -- you cannot update an app widget every 10 seconds this way.
Also, make sure that your layout is named main.xml, or update your android:initialLayout to reflect the proper name of the layout.
My solution:
public void onReceive(Context context, Intent intent)
{
String action = intent.getAction();
if (AppWidgetManager.ACTION_APPWIDGET_UPDATE.equals(action))
{
long days = (((calendar.getTimeInMillis()- date1.getTime())/1000))/86400;
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget);
//Intent AlarmClockIntent = new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_LAUNCHER).setComponent(new ComponentName("com.android.alarmclock", "com.android.alarmclock.AlarmClock"));
// PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, AlarmClockIntent, 0);
Intent Date_Change= new Intent(Intent.ACTION_DATE_CHANGED);
PendingIntent pendingIntent2=PendingIntent.getActivity(context,0, Date_Change, 0);
views.setOnClickPendingIntent(R.id.textView1, pendingIntent2);
views.setTextViewText(R.id.textView1,""+days);
//views.setOnClickPendingIntent(R.id.AnalogClock, pendingIntent);
//AppWidgetManager.getInstance(context).updateAppWidget(intent.getIntArrayExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS), views);
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
ComponentName thisWidget = new ComponentName(context, Widget.class);
appWidgetManager.updateAppWidget(thisWidget, views);
}
}