20

What I'm trying to do is have a clock widget of different sizes (i.e. 2x2, 3x3, 4x4 etc) in one apk and a configuration activity to be able to select which size to add.

From what i've learned from documentation:

  1. Widget size is specified in <appwidget-provider> tag in respective xml file
  2. Also in that file I set up the configuration activity for that provider

So it seems that size is a property of AppWidgetProvider and I'll need to somehow create another provider from the code in configuration Activity of the first one... Or am I getting this wrong and there's another way?

Is this possible at all? :) I've been told that some widgets can do this :)

Thanks in advance!

P.S. I have read this and this. First one explains how to put multiple wigets in one apk, but it's not clear how to select between them in runtime. Second one is about changing layouts, but not size...

Community
  • 1
  • 1
dimsuz
  • 8,969
  • 8
  • 54
  • 88
  • The question is about having only one entry in the Add Widget menu, and deferring the size configuration to your own config activity. I would doubt there is a way to do this - AFAIK, Android needs to know the size ahead of time of configuration. – jamesh Aug 02 '10 at 22:41
  • Hmmm, jamesh, I think you just turned my mind around! :) While reading the first related link of this question i didn't realize that if i do like it's described there, i'll have multiple widgets installed from one apk, right? This solution is quite accepatable! – dimsuz Aug 03 '10 at 08:41
  • Great. Glad to be able to help. – jamesh Aug 05 '10 at 21:28

3 Answers3

2

Do you really have to do this at runtime? It is possible to define several widgets in one .apk.

Maybe you can have a look on transdroid source? They are including two sizes of a widget in the same package.

AndroidManifest.xml used by Transdroid

Harshid
  • 5,701
  • 4
  • 37
  • 50
Eloff
  • 668
  • 7
  • 22
  • yeah, this seemed like the only way to go, as jamesh noted in comment to a head post :) To sum up: no solution to original problem, but it just seems not possible :) – dimsuz Aug 10 '10 at 08:44
  • 1
    http://code.google.com/p/transdroid/source/browse/trunk/AndroidManifest.xml getting 404 not found please provide some use content in the answer from that link – Pratik Feb 10 '12 at 06:36
1

I hope I have read your question right and think I have your answer. I could rewrite this information or just point you to it (as I would more than likely not be able to do it justice).

http://developer.android.com/guide/topics/appwidgets/index.html#Manifest

Look under "Creating an App Widget Configuration Activity". The example is good as well.

By doing it this way you may not be able to set a certain layout sizes without a lot of editing but will allow for customization by the user (which is what you want correct?)

Bactos
  • 1,233
  • 14
  • 26
  • 1
    Yes, I'm aware of the configuration activity. But I'm looking for a way to change a widget size from that activity which looks like not possible, after all... So I guess I should now cancel this question :) Thanks! – dimsuz Aug 03 '10 at 09:16
0

I have the same problem and was hoping to find a way to add only a single entry to the Widget list, and have the configuration activity decide the size, but I realize this is not possible.

When thinking about it, it's only fair: if the program would have the right to set the widget's size at runtime, one would maliciously increase the widget once added to the launcher, and occupy more real estate than it was authorized to.

So as mentioned above, the solution is to add multiple widget providers and let the user choose the size she wants. You can even use the same configuration Activity if the options are not related to style but only colors, or refresh periodicity.

Andras Balázs Lajtha
  • 2,576
  • 25
  • 32