views:

29

answers:

2

I know that the default is 30 minutes, however I am looking at making a game in a widget

This would require millisecond responses.... has anyone messed with the AlarmClock Timing that is described to use instead to achieve this? does it work well?

I haven't finished the Software Arc for the project yet because I see a lot of complaints about this on the net, so need to know if this is feasable before I go for the adventure... but the game would consist of a large widget size of one screen... many areas to click on and interact with and multiple textured animations

Looks like I can draw to a canvas and then pop it up to the bitmap to do this... but that still confuses me a bit, so if anyone knows of some good tutorials I would greatly appreciate it

this is what I was told works:

Code: Paint p = new Paint(); p.setAntiAlias(true); p.setStyle(Style.STROKE); p.setStrokeWidth(8); p.setColor(0xFFFF0000);

        Bitmap bitmap = Bitmap.createBitmap(100, 100, Config.ARGB_8888);
        Canvas canvas = new Canvas(bitmap);
        canvas.drawArc(new RectF(10, 10, 90, 90), 0, 270, false, p);

       // RemoteViews views = new RemoteViews(updateService.getPackageName(), R.layout.main);
        RemoteViews updateViews = null;

        updateViews.setImageViewBitmap(R.id.canvas, bitmap);

        ComponentName componentName = new ComponentName(updateService, DashboardAppWidgetProvider.class);
        AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(updateService);
        appWidgetManager.updateAppWidget(componentName, views);

but I am struggling with the concepts of this code having an ID for the canvas and how to use that so I have not been able to test this code

(I am a experienced c/c++/c#/dx/opengl coder first time with android and java)

Thank you!

A: 

however I am looking at making a game in a widget

I would not recommend that.

This would require millisecond responses

This is highly impractical, considering that the home screen runs in a different process than does your game code.

has anyone messed with the AlarmClock Timing that is described to use instead to achieve this? does it work well?

AlarmManager is not designed for firing multiple events per second.

but the game would consist of a large widget size of one screen

You cannot specify an app widget that is "size of one screen". You have to specify a size, and that size cannot vary by hardware screen size.

many areas to click on and interact with and multiple textured animations

Animations are not possible in app widgets.

Looks like I can draw to a canvas and then pop it up to the bitmap to do this

That will be inefficient, considering that your code and the home screen are running in separate processes.

You could write an alternative home screen and put your game in it. Then, your performance limits fall away, and you can do animations and whatever else you want. Of course, you need to add a lot of home screen functionality, or users will not want to make your app their home screen.

CommonsWare
hmm, well thank you for your imput... I agree that there are defentiely limitations for what I am doing, but I don't it is impossible.... I realize Alarmanager was not designed for this, but I have seen people use it before so what would the maximum speed it can be used at?
morty346
specifying a size is not difficult, it would be based per pixel with the smalled size phone as the size...also can always have multiple builds on the market
morty346
animations are very possible, I just have to change what the bitmap is rendering
morty346
your last comment about the canvas draw being ineffienct... why is that have not seen any documentation on that? also what does it matter that the home screen is in a different process?
morty346
@Greg Mort: "specifying a size is not difficult, it would be based per pixel with the smalled size phone as the size" -- this will not give you "size of one screen". "animations are very possible, I just have to change what the bitmap is rendering" -- the term "animations" in Android generally refer to tweened animations (not possible with app widgets) or frame animations (possible but only for pre-compiled resources). "our last comment about the canvas draw being ineffienct" -- drawing to a `Canvas` is efficient, "pop it up to the bitmap" across process boundaries will not be.
CommonsWare
@Greg Mort: "also what does it matter that the home screen is in a different process?" -- because inter-process communication is orders of magnitude slower than in-process communication.
CommonsWare
@CommonsWare - drawing to a Canvas is efficient, "pop it up to the bitmap" across process boundaries will not be.--- What are we talking for efficiency? as in wont even run? or just very slow... not like im creating a 3d game as a widget just a very simplistic interaction game that requires simple touch from the user, and simplistic "animations"....---I see you have wrote some books on this so I do appreciate you taking the time on this..So a different approach to this, I could render as a Live Wallpaper and have the interaction take place with buttons in a widget, would this be possible?
morty346
@Greg Mort: "not like im creating a 3d game as a widget just a very simplistic interaction game that requires simple touch from the user, and simplistic "animations"" -- not according to Greg Mort. Mr. Mort said "This would require millisecond responses", indicating you are looking to push dozens of frames per second of a large custom bitmap across the process boundary. That's unlikely to work well if at all. See: http://groups.google.com/group/android-developers/browse_frm/thread/2c5660a1f352c28e/389b318e21fc5844
CommonsWare
@morty346: "So a different approach to this, I could render as a Live Wallpaper and have the interaction take place with buttons in a widget, would this be possible?" -- that's conceivable. I have heard of games based on live wallpapers, though I have not used one, let alone written one. Bear in mind that the responsiveness of taps on an app widget may not be suitable for fast-twitch games.
CommonsWare
@Greg Mort: BTW, I apologize for the mildly irritated tone I'm projecting. It's been a stressful weekend, but I should not be taking it out on you.
CommonsWare
sorry for confusion... switched my user name... as for tone no big deal... i've been trying to find a way to do this widget the way I want for a good 20 hours now... so can't say im not at the end of my rope as well... just glad im finally getting some help.... its been very challenging finding help with android, I am by nature a c/c++/c# developer with dx and open gl, and the community for this seems to be much more developed, and you are the only one that has helped me at all so far...
morty346
here is a simplist animation as a widgethttp://www.androlib.com/android.application.com-spartancoders-widgetsound8bit-zjim.aspx
morty346
A: 

Animations are possible but very limited.

The process priority of homescreen widgets seems to be very very low. You can fire Alarms as many as you want, but there are some problems stopping them correctly when device is in sleepmode or so, otherwise you get in real problems with power-consumption of your device.

Any alarm you set will fire an event, but as long as cpu is working more or less you never get equal execution times for that.

Another reason for problems is the refresh rate for graphics. You can draw anything you want within such alarmevents, but the widget-drawer of android has a very bad refresh-model. You never get to know, wich graphics are really drawn to the user.

I am a developer of the new "Animated Rolling Clock Widget" ( http://www.androidzoom.com/android_applications/lifestyle/animated-rolling-clock-widget_lviw.html?nav=recategorized ) and there has been some real difficult things to manage for us to get this working as expected. If you try this one out, you can see the limitations of refreshing really fast.

For further questions in detail you may use the official email address linked to this application.

joki