android-appwidget

4x4 appwidgets are detected as 3x3 on tablets

假装没事ソ 提交于 2019-12-01 05:12:09
问题 I create an 4x4 appwidget with minWidth and minHeight set to "250dp" as it is suggested in App Widget Design Guidelines: http://developer.android.com/guide/practices/ui_guidelines/widget_design.html It is ok on every phones and phone-sized emulator I have tried but if I test it on a tablet (Xoom or Nexus 7) or on an emulator (resolution: 1280x752 with dpi 160) then the launcher detects it as 3x3 widget. What am I doing wrong? Thanks, Tamas 回答1: Try grid size = (74*n) - 2 for older api level.

How to start Activity from Android AppWidget?

你离开我真会死。 提交于 2019-12-01 02:54:25
Code like this works well. Intent configIntent = new Intent (context, WidgetConfigActivity.class); configIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); PendingIntent pIntent = PendingIntent.getActivity(context, 0, configIntent, PendingIntent.FLAG_UPDATE_CURRENT); remoteView.setOnClickPendingIntent(R.id.btn, pIntent); But I want to hide that button befor activity will appear, so I'm triing to send intent to the widget itself, perform hiding components in onReceive() method and then start activity. Problem is that I can't use startActivity() function in AppWidget. Is there

AppWidgetProvider problem

人盡茶涼 提交于 2019-11-30 15:47:25
I have an AppWidgetProvider, and I need to do some initialization when a widget is first added to the home screen. I understand that the place to do it is in the onEnabled(Context context) method. My Problem is that this method is never called (As far as I can see in the logcat). Here is my code: public class MyMonitorWidget extends AppWidgetProvider{ @Override public void onEnabled(Context context) { super.onEnabled(context); Log.v("LOG", "Widget onEnabled"); Intent intentToFire = new Intent(UpdateAlarmReceiver.ACTION_UPDATE_ALARM); context.sendBroadcast(intentToFire); } ... } And my

Service not starting on Oreo in app widget using PendingIntent

断了今生、忘了曾经 提交于 2019-11-30 13:44:31
问题 I'm using Android app widgets. I'm creating a PendingIntent object and use it in the method RemoteViews#setOnClickPendingIntent() . This is the pending intent: // The below code is called in the onUpdate(Context, AppWidgetManager, int[]) method of the AppWidgetProvider class. // Explicit intent Intent intent = new Intent(context, MyService.class); intent.setAction(MY_ACTION); intent.putExtra(EXTRA_KEY, VALUE); // Create the pending intent PendingIntent pendingIntent = PendingIntent.getService

Check if a widget is exists on homescreen using appWidgetId

倾然丶 夕夏残阳落幕 提交于 2019-11-30 09:40:04
I am using AlarmManager to update my widgets. And I want to stop it if there is no widget on homescreen. But I am facing a problem with detecting if there is no widget on home screen. As whenever I try to get the AppWidgetIds using this way: AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context); int[] appWidgetIDs = appWidgetManager .getAppWidgetIds(new ComponentName(context, Widget.class)); I get the a length of appWidgetIDs while actually there is no widget on homescreen. Why? Therefore, I would like to know if there is a way to detect that a widget id is exists on

Force Android widget to update

房东的猫 提交于 2019-11-30 04:09:30
I respond to a button press on my appwidget in the onreceive method. When the button I pressed, I want to force the widget to call the onupdate method. How do I accomplish this? Thanks in advance! Fedor Widget can't actually respond to clicks because it's not a separate process running. But it can start service to process your command: public class TestWidget extends AppWidgetProvider { public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { final int N = appWidgetIds.length; // Perform this loop procedure for each App Widget that belongs to this provider

AppWidgetProvider problem

元气小坏坏 提交于 2019-11-29 23:31:22
问题 I have an AppWidgetProvider, and I need to do some initialization when a widget is first added to the home screen. I understand that the place to do it is in the onEnabled(Context context) method. My Problem is that this method is never called (As far as I can see in the logcat). Here is my code: public class MyMonitorWidget extends AppWidgetProvider{ @Override public void onEnabled(Context context) { super.onEnabled(context); Log.v("LOG", "Widget onEnabled"); Intent intentToFire = new Intent

Check if a widget is exists on homescreen using appWidgetId

血红的双手。 提交于 2019-11-29 14:35:22
问题 I am using AlarmManager to update my widgets. And I want to stop it if there is no widget on homescreen. But I am facing a problem with detecting if there is no widget on home screen. As whenever I try to get the AppWidgetIds using this way: AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context); int[] appWidgetIDs = appWidgetManager .getAppWidgetIds(new ComponentName(context, Widget.class)); I get the a length of appWidgetIDs while actually there is no widget on homescreen

How to make a scrollable app widget?

寵の児 提交于 2019-11-29 08:07:20
As far as I have read in the Internet and official documentation, it isn't possible to make a scrollable app widget. Also all my tries failed. I even tried to subclass TextView to implement my own scroll method, but nothing worked. Are there any ways to achieve that? Btw.... there are solutions if you use for example htc sense or home desktop ++, but i want to make it available to other users which don't use this Are there any ways to achieve that? Not directly. You can always add buttons to rotate you through various options. But true scrolling is not possible. Romain Guy HTC provides

AppWidget PendingIntent not working after Launcher restart

安稳与你 提交于 2019-11-29 07:34:05
I have an AppWidget with 2 pending intents. They work most of the time, but after a while they stop responding. Only thing I have been able to pinpoint is that they are crippled after a Launcher restart, i.e. I use Launcher Pro, and sometimes fiddle with settings and have to restart it. After that they don't work at all. Here are my onRecieve() and onUpdate() methods: public void onReceive(Context context, Intent intent) { super.onReceive(context, intent); String action = intent.getAction(); if(action.equals("android.tristan.widget.digiclock.CLICK")) { PackageManager packageManager = context