android-widget
Dynamically adjusting widget’s content and layout to the size the user defined through resize. Android
Thanks to A–C , this is possible for Jellybean and above devices and is simple to implement. Below is the sample code using onAppWidgetOptionsChanged method @TargetApi(Build.VERSION_CODES.JELLY_BEAN) @Override public void onAppWidgetOptionsChanged(Context context, AppWidgetManager appWidgetManager, int appWidgetId, Bundle newOptions) { Log.d(DEBUG_TAG, “Changed dimensions”); // See the dimensions and Bundle options = appWidgetManager.getAppWidgetOptions(appWidgetId); // Get min width and … Read more
How to create android app with app widget in single application
Create and configure widget To register a widget you create a BroadcastReceiver with an intent filter for the android.appwidget.action.APPWIDGET_UPDATE action. <receiver android:icon=”@drawable/icon” android:label=”Example Widget” android:name=”MyWidgetProvider” > <intent-filter > <action android:name=”android.appwidget.action.APPWIDGET_UPDATE” /> </intent-filter> <meta-data android:name=”android.appwidget.provider” android:resource=”@xml/widget_info” /> </receiver> You also specify the meta-data for the widget via the android:name=”android.appwidget.provider attribute. The configuration file referred by this … Read more
Rotate View Hierarchy 90 degrees
I had the same problem and managed to solve it. Instead of rotating each view or the layout by hand, I used a LayoutAnimationController. First, place a file in /res/anim/ called rotation.xml <?xml version=”1.0″ encoding=”utf-8″?> <rotate xmlns:android=”http://schemas.android.com/apk/res/android” android:fromDegrees=”0″ android:toDegrees=”-90″ android:pivotX=”50%” android:pivotY=”50%” android:duration=”0″ android:fillAfter=”true”> </rotate> Then, in your Activity’s onCreate, do @Override public void onCreate(Bundle icicle) … Read more
Heterogeneous GridLayout
The issue you are facing is due to inappropriate use of the GridLayout. The GridLayout is made to show its children in a grid and you are trying to override that without extending the GridLayout. While what you want may be accomplished in code (utilizing numcolumns and columnsize), it will not be useful for multiple … Read more
RadioGroup.setEnabled(false) doesn’t work as expected
Iterate and disable each button belonging to the radio group via a loop, for example: for (int i = 0; i < testRadioGroup.getChildCount(); i++) { testRadioGroup.getChildAt(i).setEnabled(false); }
Why do I get an InstantiationException if I try to start a service? [duplicate]
You service needs to have a public no-args constructor. Otherwize, Android will not be able to instantiate it. So replace public StatisticsWidgetUpdateService(String name) { super(name); } with public StatisticsWidgetUpdateService() { super(“SOME NAME”); }
Widget for turning on/off camera flashlight in android
After a long time, I got free to solve this problem. Here is what I did. FlashlightWidgetProvider class : public class FlashlightWidgetProvider extends AppWidgetProvider { @Override public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { Intent receiver = new Intent(context, FlashlightWidgetReceiver.class); receiver.setAction(“COM_FLASHLIGHT”); receiver.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, appWidgetIds); PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, receiver, 0); RemoteViews views = new … Read more
Launching activity from widget
Bringing this way back from the dead, but I had a similar problem and I think I finally solved it… like you, I had a PendingIntent that I attached to the RemoteView. Sometimes it would work, and sometimes it would fail. It was driving me crazy. What I found from a tooltip on the PendingIntent.getActivty() … Read more
Resetting Search Widget (SearchView) value
You might also try the following: searchView.setQuery(“”, false); searchView.clearFocus();