I am trying to make a simple widget that will play a movie from the sdcard when clicked on. This seems simple enough, and by following tutorials I've come up with the following code, but it seems the onclick is never setup.
Manifest:
<receiver android:name="WidgetProvider" android:label="DVD Cover">
<intent-filter>
<action
android:name="android.appwidget.action.APPWIDGET_UPDATE"/>
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="#xml/appwidget_info_2x4"/>
</receiver>
Layout (widget.xml):
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/holder"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ff777777"
>
<ImageView
android:id="#+id/cover"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:textColor="#000000"
/>
</LinearLayout>
appwidget.xml:
<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:minWidth="200dip"
android:minHeight="300dip"
android:updatePeriodMillis="180000"
android:initialLayout="#layout/widget"
>
</appwidget-provider>
WidgetProvider.java:
public class WidgetProvider extends AppWidgetProvider {
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
String movieurl = Environment.getExternalStorageDirectory().getPath() + "/Movie.mp4";
Intent notificationIntent = new Intent(Intent.ACTION_VIEW);
notificationIntent.setDataAndType(Uri.parse(movieurl), "video/*");
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent,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.widget);
views.setOnClickPendingIntent(R.id.holder, contentIntent);
// Tell the AppWidgetManager to perform an update on the current app widget
appWidgetManager.updateAppWidget(appWidgetIds, views);
}
}
Any help would be greatly appreciated.
Thanks,
Josh
Try this code
First create a variable something like this
public static String CLICK_ACTION = "com.widget.CLICK";
Now inside onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) method set pending intent like this
for (int j = 0; j < appWidgetIds.length; j++) {
RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget);
Intent clickIntent = new Intent(context, WidgetProvider.class);
clickIntent.setAction(CLICK_ACTION);
clickIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, appWidgetIds[j]);
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, clickIntent, PendingIntent.FLAG_UPDATE_CURRENT);
remoteViews.setOnClickPendingIntent(R.id.cover, pendingIntent_);
}
Then in onReceive(final Context context, Intent main_intent) method do like this.
if (main_intent.getAction().equals(CLICK_ACTION)) {
//Start your video intent here
Intent notificationIntent = new Intent(Intent.ACTION_VIEW);
notificationIntent.setDataAndType(Uri.parse(movieurl), "video/*");
context.getApplicationContext().startActivity(notificationIntent);
}
Related
I have 2 possible layouts of widget that user can change via preference activity, I mean light and dark. Both looks simillary, onlu colors are different. Event ids are those same. I want to give a possibility to click whole widget, what will open activity and send necessery data via intent. My code in AppWidgetProvider doen't work at all.
Here it is:
private final String ACTION = "CLICK_MY_BUTTON";
#Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
super.onUpdate(context, appWidgetManager, appWidgetIds);
SharedPreferences theme = Data.getPreferences(context, Data.Prefs.THEME);
boolean dark = theme.getString(Data.widgetsThemeSetings, "1").equals("1");
int layoutId = dark?R.layout.widget_dark:R.layout.widget_light;
for (int i:appWidgetIds) {
Intent intent = new Intent(context, MainActivity.class);
intent.putExtra("from", "widget");
intent.setAction(ACTION);
int id = Calendar.getInstance().get(Calendar.DAY_OF_YEAR);
intent.putExtra("id", id<60?id:id-1);
intent.putExtra("widgetID", i);
RemoteViews remoteViews = new RemoteViews(context.getPackageName(), layoutId);
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 1, intent, 0);
remoteViews.setOnClickPendingIntent(R.id.widget_relative_main, pendingIntent);
String output = "";
for (String s:HolidayCalendar.getInstance(context).getTodayTexts()) {
output += "\n\n" + Data.pointer + " " + s;
}
remoteViews.setTextViewText(R.id.widget_text_holiday, output.substring(2));
appWidgetManager.updateAppWidget(i, remoteViews);
}
}
and one of my widget layouts:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/widget_relative_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/rounded_widget_dark"
android:orientation="vertical" >
<TextView
android:id="#+id/widget_text_today"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="center"
android:text="#string/today_is"
android:textColor="#FFF"
android:textSize="20sp" />
<TextView
android:id="#+id/widget_text_holiday"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/widget_text_today"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:textColor="#FFF" />
</RelativeLayout>
How to get it working? I have no idea what may be incorrect...
this is my working code. this will work.
for (int i = 0; i < N; i++) {
int awID = ids[i];
RemoteViews views = new RemoteViews(getPackageName(),
R.layout.widget_layout);
Intent intent = new Intent(this, your intented class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//views.setTextViewText(R.id.widgetcount, visitstext);
PendingIntent pendingIntent = PendingIntent.getActivity(this,
0, intent, 0);
views.setOnClickPendingIntent(R.id.widgetimage, pendingIntent);
manager.updateAppWidget(awID, views);
}
I am having trouble making my Widget clickable. The following code is working partially. My Widget shows a ListView with Items. When clicking into the Widget where no Item is displayed, the Intent works and the Activity starts. But when clicking on an Item of the ListView nothing happens.
Here is the Code:
WidgetProvicer:
public void onUpdate(final Context context, final AppWidgetManager appWidgetManager, final int[] appWidgetIds) {
for (final int iD : appWidgetIds) {
final RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout
.widget_layout);
final Intent intent = new Intent(context, TickWidgetService.class);
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, iD);
intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
remoteViews.setRemoteAdapter(R.id.WidgetItem, intent);
remoteViews.setEmptyView(R.id.WidgetItem, R.id.empty_view);
final Intent activityIntent = new Intent(context, MainActivity.class);
final PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, activityIntent, 0);
remoteViews.setOnClickPendingIntent(R.id.Widget, pendingIntent);
appWidgetManager.updateAppWidget(iD, remoteViews);
appWidgetManager.notifyAppWidgetViewDataChanged(iD, R.id.WidgetItem);
}
super.onUpdate(context, appWidgetManager, appWidgetIds);
}
widget_layout.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/Widget"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ListView
android:id="#+id/WidgetItem"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:divider="#D3D3D3"
android:dividerHeight="1dp"/>
<TextView
android:id="#+id/empty_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/darker_gray"
android:gravity="center"
android:text="#string/emptytext"
android:visibility="gone"/>
</LinearLayout>
The ListViewItems have no Buttons or anything.
Thanks for your help!
finally it is working:
in the Profider onUpdate:
final Intent activityIntent = new Intent(context, MainActivity.class);
final PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, activityIntent, PendingIntent.FLAG_UPDATE_CURRENT);
remoteViews.setPendingIntentTemplate(R.id.WidgetItem, pendingIntent);
and in the ViewsFactory getViewAt:
Bundle infos = new Bundle();
infos.putInt(TickWidgetProvider.WIDGET_LISTID, this.listId);
final Intent activityIntent = new Intent();
activityIntent.putExtras(infos);
remoteView.setOnClickFillInIntent(R.id.widgetListItemLayout, activityIntent);
Do not know where I found it, but this example helped me making it work:
https://github.com/commonsguy/cw-advandroid/tree/master/AppWidget/LoremWidget
I have simple app with widget. Widget works good for some time. After open and close another app (e.g. some game for the most cases) my widget stops responding to clicks. Do you know how to fix widget freezing please?
I folowed some similar situation, but with no success: Android widget not responding to touches, Android widget buttons stop working, Android Widget stops working randomly, atc.
My actual Widget.class:
public class Widget extends AppWidgetProvider{
private DBManager dbManager;
#Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
final int N = appWidgetIds.length;
String URI_SCHEME = "A";
// 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, MainOverview.class);
Intent intent2 = new Intent(context, AddFragment.class);
intent.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
intent2.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, appWidgetId);
intent2.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, appWidgetId);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
PendingIntent pendingIntent2 = PendingIntent.getActivity(context, 0, intent2, PendingIntent.FLAG_UPDATE_CURRENT);
// Get the layout for the App Widget and attach an on-click listener
// to the button
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget);
views.setOnClickPendingIntent(R.id.widget_all, pendingIntent);
views.setOnClickPendingIntent(R.id.widget_add, pendingIntent2);
Uri data = Uri.withAppendedPath(
Uri.parse(URI_SCHEME + "://widget/id/")
,String.valueOf(appWidgetId));
intent.setData(data);
intent2.setData(data);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM", Locale.ENGLISH);
final Calendar calendar = new GregorianCalendar();
String text_date = sdf.format(calendar.getTime());
CharSequence sumd = (CharSequence) text_date;
views.setTextViewText(R.id.widget_date, sumd);
dbManager = new DBManager(context);
dbManager.open();
int totalPayed = dbManager.getTotalPayed(text_date);
CharSequence sumw = Integer.toString(totalPayed);
views.setTextViewText(R.id.widget_summary, sumw);
dbManager.close();
// Tell the AppWidgetManager to perform an update on the current app widget
appWidgetManager.updateAppWidget(appWidgetId, views);
// Update the widgets via the service
context.startService(intent);
context.startService(intent2);
}
super.onUpdate(context, appWidgetManager, appWidgetIds);
}
#Override
public void onReceive(Context context, Intent intent)
{
super.onReceive(context, intent);
}
}
My actual widget_provider.xml:
<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:initialLayout="#layout/widget"
android:minHeight="40dp"
android:minWidth="110dp"
android:resizeMode="horizontal|vertical"
android:previewImage="#drawable/logo"
android:updatePeriodMillis="36000000" >
</appwidget-provider>
My actual part of AndroidManifest.xml:
<receiver android:name=".Widget"
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/widget_provider" />
</receiver>
I have a homescreenwidget in Android with two buttons. Both buttons should call the same activity ( class ) just use a different intent plus intent extras, to know which button called the class.
For now only button1 is working and calling the activity. I also receive the keyvalue in the called Activity.
How can i make the second button work?
Here's my code:
public void onUpdate(Context context, AppWidgetManager appWidgetManager,
int[] appWidgetIds) {
super.onUpdate(context, appWidgetManager, appWidgetIds);
for ( int i =0; i<appWidgetIds.length ; i++){
int appWidgetId = appWidgetIds[i];
Intent intent2 = new Intent(context, Main.class);
Intent intent1 = new Intent(context, Main.class);
// Intent put extras Button 1
String bread1 = "secure";
Bundle basket1 = new Bundle();
basket1.putString("key", bread1);
intent1.putExtras(basket1);
// Intent put extras Button 2
String bread2 = "insecure";
Bundle basket2 = new Bundle();
basket2.putString("key", bread2);
intent2.putExtras(basket2);
PendingIntent pending1 = PendingIntent.getActivity(context,0,intent1, 0);
PendingIntent pending2 = PendingIntent.getActivity(context, 0, intent2, 0);
RemoteViews views1 = new RemoteViews(context.getPackageName(),R.layout.maina);
RemoteViews views2 = new RemoteViews(context.getPackageName(),R.layout.maina);
views1.setOnClickPendingIntent(R.id.button1, pending1);
views2.setOnClickPendingIntent(R.id.button2, pending2);
appWidgetManager.updateAppWidget(appWidgetId, views1);
appWidgetManager.updateAppWidget(appWidgetId, views2);
here is the maina.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" android:weightSum="1" android:orientation="vertical">
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="TextView" android:id="#+id/tvWidget" android:textAppearance="?android:attr/textAppearanceLarge"></TextView>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" android:weightSum="1" android:orientation="horizontal">
<Button android:text="#string/button1" android:id="#+id/button1" android:layout_height="wrap_content" android:layout_width="wrap_content"></Button>
<Button android:text="#string/button2" android:id="#+id/button2" android:layout_height="wrap_content" android:layout_width="wrap_content"></Button>
</LinearLayout>
</LinearLayout>
#Arnold you have created 2 PendingIntent which are....
PendingIntent pending1 = PendingIntent.getActivity(context,0,intent1, 0);
PendingIntent pending2 = PendingIntent.getActivity(context, 0, intent2, 0);
Where PendingIntent.getActivity(Context context, int requestCode, Intent intent, int flags) has 4 parameters. You have to send different "requestCode" for different PendingIntents.
Your code should be....
PendingIntent pending1 = PendingIntent.getActivity(context,0,intent1, PendingIntent.FLAG_UPDATE_CURRENT);
PendingIntent pending2 = PendingIntent.getActivity(context, 1, intent2, PendingIntent.FLAG_UPDATE_CURRENT);
in the main class you need to create this...
String value;
#Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
Bundle b=intent.getExtras();
try{
value=b.getString("key");
}
catch (Exception e) {
// TODO: handle exception
}
super.onReceive(context, intent);
}
with the onUpdate code....
#Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager,
int[] appWidgetIds) {
// Get all ids
ComponentName thisWidget = new ComponentName(context,
main.class);
int[] allWidgetIds = appWidgetManager.getAppWidgetIds(thisWidget);
for (int widgetId : allWidgetIds) {
// Create some random data
RemoteViews remoteViews = new RemoteViews(context.getPackageName(),
R.layout.main);
// Register an onClickListener for 1st button
Intent intent = new Intent(context, main.class);
intent.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS,allWidgetIds);
intent.putExtra("key", "1st Button");
PendingIntent pendingIntent = PendingIntent.getBroadcast(context,
0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
remoteViews.setOnClickPendingIntent(R.id.button1, pendingIntent);
// Register an onClickListener for 2nd button............
Intent intent2 = new Intent(context, main.class);
intent2.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
intent2.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS,allWidgetIds);
intent2.putExtra("key", "2nd Button");
PendingIntent pendingIntent2 = PendingIntent.getBroadcast(context,
1, intent2, PendingIntent.FLAG_UPDATE_CURRENT);
remoteViews.setOnClickPendingIntent(R.id.button2, pendingIntent2);
appWidgetManager.updateAppWidget(widgetId, remoteViews);
}
}
Then you can check whether value=1st Button or value=2nd Button to know which Button has been clicked.
It should work... IF it does not work please let me know what is the problem...
I had a similar problem with using 2 buttons on a widget. I set OnClickPendingIntents on both of them, distinguished by different setExtra() calls. But only the latter intent was called, even when clicking the first button.
I found 2 solutions:
- assign different actions to both PendingIntents
- on the second PendingEvent set the PendingEvent.FLAG_CANCEL_CURRENT flag
I am quite unfamiliar with PendingEvents and Widgets, so I can't see the pros and cons and will stick to the first solution.
Maybe that might help you with your problem, too.
Your widget will only have 1 remote view. Try changing the end of your code snippet to:
RemoteViews remoteView = new RemoteViews(context.getPackageName(),R.layout.maina);
remoteView.setOnClickPendingIntent(R.id.button1, pending1);
remoteView.setOnClickPendingIntent(R.id.button2, pending2);
appWidgetManager.updateAppWidget(appWidgetId, remoteView);
Failing that, it would be useful to see your layout in R.layout.maina.
In my case:
remoteViews.setOnClickPendingIntent(R.id.widget_head, touch_man(context));
remoteViews.setOnClickPendingIntent(R.id.widget_head2, touch_woman(context));
public static PendingIntent touch_man(Context context) {
Intent intent = new Intent();
intent.setAction("touch_man");
return PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
}
public static PendingIntent touch_woman(Context context) {
Intent intent = new Intent();
intent.setAction("touch_woman");
return PendingIntent.getBroadcast(context, 1, intent, PendingIntent.FLAG_UPDATE_CURRENT);
}
In AndroidManifest
<receiver
android:name="Receiver"
android:label="widgetBroadcastReceiver" >
<intent-filter>
<action android:name="touch_man" />
<action android:name="touch_woman"/>
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="#xml/demo_widget_provider" />
</receiver>
It's working.
i have a widget to my application that is refreshed every 10 sec. If i change the language of the phone, the widget stops working. I mean, the textviews do not load the texts until they are refreshed (so after 10sec). I added a functionality that the user can open the app by clicking on the widget (an ImageView). This problem still stays.
This whole problem appears also when I restart the phone. I have to wait 10 secs for the textviews to load the texts, but I cannot click on the widget. I may change this interval to 1 sec, what would solve this issue (making it almost invisible for the user). But like I said, I still cannot click on the widget.
Here is the full AppWidgetProvider class:
public class HelloWidget extends AppWidgetProvider {
public static String ACTION_WIDGET_CONFIGURE = "ConfigureWidget";
public static String ACTION_WIDGET_RECEIVER = "ActionReceiverWidget";
private static final int REQUEST_CODE_ONE = 10;
String elso;
public static String MY_WIDGET_UPDATE = "MY_OWN_WIDGET_UPDATE";
#Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
super.onUpdate(context, appWidgetManager, appWidgetIds);
final int N = appWidgetIds.length;
for (int i=0; i<N; i++) {
int appWidgetId = appWidgetIds[i];
updateAppWidget(context, appWidgetManager, appWidgetId);
Toast.makeText(context, "onUpdate(): " + String.valueOf(i) + " : " + String.valueOf(appWidgetId), Toast.LENGTH_SHORT).show();
}
Intent intent = new Intent(context, UpdateService.class);
context.startService(intent);
RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.main);
Intent configIntent = new Intent(context, MainActivity.class);
configIntent.setAction(ACTION_WIDGET_CONFIGURE);
PendingIntent configPendingIntent = PendingIntent.getActivity(context, REQUEST_CODE_ONE, configIntent, PendingIntent.FLAG_UPDATE_CURRENT);
remoteViews.setOnClickPendingIntent(R.id.ImageView01, configPendingIntent);
appWidgetManager.updateAppWidget(appWidgetIds, remoteViews);
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(System.currentTimeMillis());
Intent myIntent = new Intent(context, UpdateService.class);
PendingIntent pendingIntent = PendingIntent.getService(context, 0, myIntent, 0);
AlarmManager alarmManager = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
Calendar calendar2 = Calendar.getInstance();
calendar2.setTimeInMillis(System.currentTimeMillis());
calendar2.add(Calendar.SECOND, 1);
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, calendar2.getTimeInMillis(), 50*1000, pendingIntent);
}
#Override
public void onReceive(Context context, Intent intent) {
super.onReceive(context, intent);
if(MY_WIDGET_UPDATE.equals(intent.getAction())){
Bundle extras = intent.getExtras();
if(extras!=null) {
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
ComponentName thisAppWidget = new ComponentName(context.getPackageName(), HelloWidget.class.getName());
int[] appWidgetIds = appWidgetManager.getAppWidgetIds(thisAppWidget);
if (appWidgetIds.length > 0) {
new HelloWidget().onUpdate(context, appWidgetManager, appWidgetIds);
}
}
}
}
public static void updateAppWidget(Context context, AppWidgetManager appWidgetManager,
int appWidgetId){
}
}
From this code this is the part that serves for opening the MainActivity.class of the app when the user clicks on the widget:
RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.main);
Intent configIntent = new Intent(context, MainActivity.class);
configIntent.setAction(ACTION_WIDGET_CONFIGURE);
PendingIntent configPendingIntent = PendingIntent.getActivity(context, REQUEST_CODE_ONE, configIntent, 0);
remoteViews.setOnClickPendingIntent(R.id.ImageView01, configPendingIntent);
appWidgetManager.updateAppWidget(appWidgetIds, remoteViews);
This is the Manfiest part:
<receiver android:name=".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/widget_provider" />
</receiver>
And this is the widget_provider.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="86400000"
android:initialLayout="#layout/main"
/>
I have a widget to my application that is refreshed every 10 sec [...]
I may change this interval to 1 sec [...]
In short: That's very bad practice. You should (at maximum) only update every 30 minutes.
By refreshing your Widget every 10 seconds, you kill the battery so fast that nobody will use it. Instead, you could add an "refresh"-button which then manually refreshes the Widget.
Also, in the onUpdate-method, you don't need to call the super-method.
And the onReceive-method does not need to be overridden! The onUpdate-method is automatically called when you use an AppWidgetProvider (not if you use a normal BroadcastReceiver). See here.
Last but not least, you should check if your "call-Activity"-code gets reached and try to debug it with the Log-class. The LogCat-Output might also help solving this.
Can you add this flag
PendingIntent configPendingIntent = PendingIntent.getActivity(context, REQUEST_CODE_ONE, configIntent, PendingIntent.FLAG_UPDATE_CURRENT);
Also check Logcat for any exception it throws when you click on the widget.