Android :: Programmatically Create / Destroy AppWidgets?
Mar 5, 2010Is it possible to programmatically create and/or destroy AppWidgets?
View 7 RepliesIs it possible to programmatically create and/or destroy AppWidgets?
View 7 RepliesThere is a given set of predefinied Views that can be used in layouts for AppWidgets. How can a customized View added to this list?
The minimum requirement is that the class is annotated with RemoteView. What else is necessary to be acceptable as view in the layout.xml?
I frequently run into the problem that I have to preserve state between several invocations of an activity (i.e. going through several onCreate()/onDelete() cycles). Unfortunately, Android's support for doing that is really poor. As an easy way to preserve state, I thought that since the class is only loaded once by the class loader, that it would be safe to store temporary data that's shared between several instances of an activity in a static Bundle field. However, occasionally, when instance A creates the static bundle and stores data in it, then gets destroyed, and instance B tries to read from it, the static field is suddenly NULL. Doesn't that mean that the class had been removed and reloaded by the classloader while the activity was going through a create/destroy cycle? How else could a static field suddenly become NULL when it was referencing an object before?
View 2 Replies View RelatedI'm trying to create table row and place 3 elements: EditText - EditText - ImageButton as following:................
View 2 Replies View RelatedI want to create an XML file to Store my Application Settings into. ( I can't use SharedPrefs because i want that Settings file later to be accessed by Some other Code.)
I can easily create an XML with java's code and store it in File too. but in Android I can create xml with the same java code but can't save it into the file coz they have removed the package javax.xml.transform from SDK.
I am Attaching the Java code here...
CODE:....................
I am new in Android. whats the wrong with the following code:
CODE:.................
I want to launch an Activity with a webView as its content from current Activity. This new activity needs to be transparent and webview should be in the center. I looked around the web but only solutions I found were using style xmls. I want to do it using pure code i.e. no xml declarations. if anybody has come across this then please shed some light.
View 1 Replies View RelatedI know how to create Open/WEP/PSK/PSK2 configuration programmatically.
CODE:...........
But how do I create one for '802.1x EAP'?
Looking into the source code at:
CODE:..............
Seems to do the work but 'config.eap' is not accessable from my application.
Is there a way to configure EAP types or is it not possible?
Is there a way i can create a view and add some textviews into it ? programmatically ? any sample code?
View 2 Replies View RelatedI need some help with the following scenario, as I am so used to make all of my layouts with XML, but now I have a situation where that won't work.
I am working on the second version of my app that delivers news, in the comments section I used to use a listview to display user comments, but it doesn't work that great for comments that could be anywhere from 5 to 500+ characters long. So I want to create a whole bunch of TextViews in a scrollview and stack them below each other.
My best guess was this, although it is definitely wrong because it only shows one comment. I assume I have to use some kind of LayoutParams and so I've looked into it but am still not sure how exactly to use them.
I'm all new to Android and I'm trying to create a spinner programmatically and feeding it with data from an array, but Eclipse gives me a warning that I can't handle.
Here's what I got:
This ArrayList holds the elements that should be in the spinner (gets filled from a file later on):
ArrayList<String> spinnerArray = new ArrayList<String>();
This is code ...
Now the second line (ArrayAdapter...) gives me a warning in Eclipse saying "ArrayAdapter is a raw type... References to generic type ArrayAdapter<T> should be parameterized", I have no idea how to fix this (or what that means in the first place :) ).
It's just a warning and the App seems to run alright, but I'd still like to understand what's wrong and fix it.
How to create a folder in main screen programmatically?
View 5 Replies View RelatedIn ApiDemo, there is a progressBar demo. It creates a horizontal progress bar with a xml.
<ProgressBar android:id="@+id/progress_horizontal" style="?android:attr/progressBarStyleHorizontal" android:layout_width="200dip" android:layout_height="wrap_content" android:max="100" android:progress="50" android:secondaryProgress="75" />
But how to create one programmatically? If just new ProgressBar(fContext), it is Default ProgressBar style.
Does Android have a "best practices" guideline on creating & populating the db/tables programmatically vs. deploying a .db file in assets?
What are the pros/cons of both approaches?
I have a db with big long strings in several columns, and about 50 rows, so writing the insert statements alone would take quite some space. It seems a waste.
I have an xml layout that will display a grid made up of textviews within tablerows. The textview names are cell00, cell01, etc. At runtime, my program will determine which cell needs to be changed.
Is there a way get format a name so that it can be passed to the findViewById method at runtime? For example, if cell00 is needed, how can I generate the parm in this code?
TextView currcell = (TextView) findViewById(R.id.cell00)
Something like "cell"+00 doesn't compile because the findViewById method doesn't accept a String type. I don't want have every textview name in the grid hardcoded in the program - there must be a better way.
public class SamActivity extends Activity
{
private Paint mPaint;
private MaskFilter mEmboss;
private MaskFilter mBlur;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
[code].....
This is my code.In this i draw a line over the image.Now i want to know how to create button programatically?
We have discovered a potential bug in the implementation of AppWidgets. Here is a simple reproducer.
Attached is the code for an application containing a TestActivity and a TestWidget. TestActivity extends MapActivity and TestWidget is a simple widget provider which updates a TextView every 2 seconds. Now if the TestActivity is launched with no instance of TestWidget running, it works just fine. But if the TestActivity is launched after placing the TestWidget on the home, it results in ClassNotFoundException. Here is what we get:
CODE:.............
So it seems we have an inconsistency in the way the class loader works for the same apk.
WORKS - Launch the application by itself, without invoking the Widget. DOES NOT WORK - Create a Widget on the Home screen and then launch the application from the launcher.
The source code for this application (http://www.yousendit.com/ download/TzY3ZGVhZy96NE4zZUE9PQ) has been attached. Hope someone from the Android team can shed light on this behavior.
This error is seen on the 1.5r3 SDK. Not sure if this has been addressed in 1.6 and 2.0 SDKs..
I'm trying to make an AppWidget, and for some reason the Eclipse debugger doesn't suspend on any of the breakpoints I set (but I know the code is executed because I see it working on the emulator). I don't have this problem with other 'regular' apps (non AppWidgets). Is this a known limitation, or is it just a problem on my installation?
View 4 Replies View RelatedWe have created an AppWidget that takes user inputted text into an EditText and displays a calculated amount of text inside a TextView on the Home Screen. We calculate the amount of text based on the AppWidgetInfo.minWidth, minHeight attributes. We do this to simulate scrolling; we cut up the user-inputted text into chunks that will fit into the widget and swap them based on button clicks.
When we save the widget with the device in Landscape mode, it calculates the appropriate amount of text for Landscape mode and displays it in the widget. The problem is when the user changes orientation of the device to Portrait mode (without opening the widget and resaving the text), the calculated amount of text for Landscape mode is still displayed. This also happens in the vice versa case (the user is in Portrait and saves, etc.)
How can we tell our AppWidget to recalculate the amount of text displayed on screen orientation change? Is this possible? How would you solve this problem?
I'm making an Android AppWidget to sit on the home screen.
The user's home screen space is precious, so I want the widget to be small. The ideal size would be 2x1 cells.
Some documentation suggests you can have any size you like?
But the AppWidget graphical design guidelines imply that only standard sizes are supported: 4x1, 3x3, 2x2.
Does that refer to the available PhotoShop templates or is it a limitation of Android itself?
I'm finding that a 2x1 widget works on my actual device (HTC Wildfire) but expands to 2x2 on the emulator.
HTC have their own special implementation of the home screen, so maybe my widget will only work at 2x1 on HTC devices?
Is there any way to create a 2x1 widget, or should I use a standard size?
My widget was adapted from the Simple Wiktionary sample.
The manifest has android:minWidth="146dip" and android:minHeight="72dip".
There's a RelativeLayout with android:layout_width="fill_parent" and android:layout_height="wrap_content"
I'm just starting with Android, so apologies in advance if this is a silly question. :)
I'm writing a widget. Currently, I'm have a simple ImageView, and calling RemoteViews.setImageViewBitmap(). I'm using a service to do the updates.
I thought it might be a good idea to reuse an existing RemoteViews instance, so I'm only querying it the first time around, and subsequently simply call setImageViewBitmap() with the new image.
This works well initially, but after some time I first start getting "!!! FAILED BINDER TRANSACTION !!!" errors, and later, an OutOfMemory exception.
Simply creating a new RemoveViews instance every time works flawlessy on the other hand. I'm just curios why that would be, any ideas?
Can anyone tell me how to make a flexible AppWidgets in android according to the screen size.
I want to make a full screen widget, but when it change screen size, i want to make it flexible.
I have developed an application which is working fine.
In that i have used some static variables and also set Application level variables.
My problem is that even after setting finish() on each activity, application is showing in Running mode.
After closing the application, when i start the application after sometime, it will set the last changes.
How can i destroy my application?
I have an activity defined as below:
CODE:............
A strange thing is that, when running on emulator, and the back key is pressed, the activity was destroyed (I saw onDestroy() called in log). But when running on my Nexus One phone, and the back key is pressed, the activity is not destroyed (I didn't see onDestroy() called in log).
what puzzle me so much is that i can't destroy a GLSurfaceView while i don't want to exit the activity.
the fact is when i destroy a GLSurfaceView which had show in the screen (that means it has binded to the activity's SurfaceHolder), the activity exits without any prompting. Perhaps ,the Context which provided in the Construction of GLSurfaceView joins the two things together. so my conclusion is that a GLSurfaceView can only be destroyed when exit the activity. is there anyway to destroy a GLSurfaceView without exit activity? is there someone can provide a clue?
I have an Activity with an inner Handler. The problem is that after the activity is destroyed, the Handler is receiving messages for the destroyed activity. This breaks things because the activity is in an inconsistent state. I'm thinking this might be a bug in Android - it should probably delete all the messages in the queue when the activity is destroyed. There doesn't appear to be any way I can manually delete all messages in the queue (except by calling removeMessage(int what) with every possible variation of what, which seems a bit ridiculous). The only other solution I can think of is to create my own is_destroyed instance variable and check it in handleMessage(), but again that seems like a ridiculous hack. Has anyone come across this problem before?
View 5 Replies View RelatedI have a activity MyActivity, which "kills" yourself using the finish () method. The problem is: after the kill operation, method onDestroy is called, but the object of type MyActivity is never garbage-collected (I forced the GC run). It is causing a memory leak, because MyActivity is launched many times, by other activities. Does anyone know when the Activity object is supposed to be garbage- collected, and what can be done to avoid the issue I mentioned?
View 2 Replies View RelatedI have an app that works only in portrait mode, and I have made the changes in my manifest file for every activity the orientation to be portrait. But when I rotate the device, the activity recreates again.
How to not destroy the activity?
I have one doubt about back button. If one activity is running on foreground and if I press back button then it will destroy the activity. Now my question is is destroy and kill a process is different? cause if I open DDMS I can see same process is running..Only if I stop that process in DDMS then only it disappear. Is that process will take any memory space after pressing back button..
View 6 Replies View Related"It's not limited to Android devices, but it seems that increasingly Android more than other platforms is shipping with the worst mobile bloatware. It's a bad trend that's going to lead to consumer backlash and it's destroying the credibility of Google's Android vision."
Entelligence: Will carriers destroy the Android vision? - Engadget